Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Useful cmd line thing i noticed
New Posts  All Forums:Forum Nav:

Useful cmd line thing i noticed

post #1 of 11
Thread Starter 
i looked for the cmd line tips thread and couldnt find it (didnt look very hard lol)

but i thought id share this with ya people that dont know about it

everyone knows you can jump up a directory with "cd .." but most people dont know that .. is a valid directory path and so you can do cool stuff while browsing or searching for files

say you have a pictures directory, in that dir you have several sub dirs such as blonde redhead and DDs

you can go from /pictures/blonde/ over to /pictures/redhead/ by typing cd ../redhead its much faster than typing cd .. and then cd redhead

very useful for speeding up your cmd line usage another way cmd line can be faster than your gui by far lol

EDIT: can also use multiples like if you wanna jump up two dirs just do cd ../..
Edited by EntTheGod - 2/22/11 at 9:02am
Kinda meh now...
(13 items)
 
  
CPUMotherboardGraphicsRAM
PhII 940 BE asus M4N82 Deluxe 2x 8800gts(g92) 2x 1g ocz ddr2 1066 
Hard DriveOptical DriveOSMonitor
/dev/sd[abc] /dev/sr0 WinXP/Linux 22in acer 
PowerCaseMouseMouse Pad
950w rosewill timebomb Antec 900 (2small) Voodoo Deathadder (RED!) X-Trac Pads Ripper XL 
  hide details  
Reply
Kinda meh now...
(13 items)
 
  
CPUMotherboardGraphicsRAM
PhII 940 BE asus M4N82 Deluxe 2x 8800gts(g92) 2x 1g ocz ddr2 1066 
Hard DriveOptical DriveOSMonitor
/dev/sd[abc] /dev/sr0 WinXP/Linux 22in acer 
PowerCaseMouseMouse Pad
950w rosewill timebomb Antec 900 (2small) Voodoo Deathadder (RED!) X-Trac Pads Ripper XL 
  hide details  
Reply
post #2 of 11
You can also use stuff like:

cd ~/path

and if you have a folder which contains folders you can do something like this also:

mkdir /directory/{dir1,dir2,dir3}

Quote:
[h1tman@bastion ~]$ mkdir ocn
[h1tman@bastion ~]$ mkdir ocn/{dir1,dir2,dir3}
[h1tman@bastion ~]$ ls ocn/
dir1 dir2 dir3
[h1tman@bastion ~]$
There's a ton of bash tricks out there.
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
post #3 of 11
Thread Starter 
Quote:
Originally Posted by kc-tr View Post
You can also use stuff like:

cd ~/path

and if you have a folder which contains folders you can do something like this also:

mkdir /directory/{dir1,dir2,dir3}



There's a ton of bash tricks out there.

knew that ~ was /home/username but i didnt know the curly brace with commas trick

had to try that out... you can also do subdirectories with it so the next command you could time could be

mkdir /directory/{dir1/next1,dir2/next2,dir3/next3}

very cool trick... create file system trees in the matter of seconds

i imagine you could also throw some .. in there if you wanted to create directories up a few paths as well lol
Kinda meh now...
(13 items)
 
  
CPUMotherboardGraphicsRAM
PhII 940 BE asus M4N82 Deluxe 2x 8800gts(g92) 2x 1g ocz ddr2 1066 
Hard DriveOptical DriveOSMonitor
/dev/sd[abc] /dev/sr0 WinXP/Linux 22in acer 
PowerCaseMouseMouse Pad
950w rosewill timebomb Antec 900 (2small) Voodoo Deathadder (RED!) X-Trac Pads Ripper XL 
  hide details  
Reply
Kinda meh now...
(13 items)
 
  
CPUMotherboardGraphicsRAM
PhII 940 BE asus M4N82 Deluxe 2x 8800gts(g92) 2x 1g ocz ddr2 1066 
Hard DriveOptical DriveOSMonitor
/dev/sd[abc] /dev/sr0 WinXP/Linux 22in acer 
PowerCaseMouseMouse Pad
950w rosewill timebomb Antec 900 (2small) Voodoo Deathadder (RED!) X-Trac Pads Ripper XL 
  hide details  
Reply
post #4 of 11
Ah the joys of command line tools
    
CPUMotherboardGraphicsRAM
Phenom II X3 720 @ 3.5 (1.39v) Gigabyte GA-MA790XT-UD4P ASUS 5850 @ 880/1180 (1.118v) 4gb 1333mhz G.Skill DDR3 
Hard DriveHard DriveHard DriveHard Drive
64gb Crucial M4 SSD 3x 250gb WD2500JD - RAID0 1tb WD1001FALS 1tb WD10EARS 
Optical DriveCoolingOSMonitor
Pioneer DLDVD/CDRW Arctic Freezer Pro 64 Win 7 64bit Ultimate E2305 LG 23" LED 
KeyboardPowerCaseMouse
Filco Majestouch II Ninja Tenkeyless Fortron BlueStorm II 500w CM 690II Advanced Razer DeathAdder 
Mouse PadAudioAudio
generic Echo Miamidi PCI M-Audio BX5a Studio Monitors 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Phenom II X3 720 @ 3.5 (1.39v) Gigabyte GA-MA790XT-UD4P ASUS 5850 @ 880/1180 (1.118v) 4gb 1333mhz G.Skill DDR3 
Hard DriveHard DriveHard DriveHard Drive
64gb Crucial M4 SSD 3x 250gb WD2500JD - RAID0 1tb WD1001FALS 1tb WD10EARS 
Optical DriveCoolingOSMonitor
Pioneer DLDVD/CDRW Arctic Freezer Pro 64 Win 7 64bit Ultimate E2305 LG 23" LED 
KeyboardPowerCaseMouse
Filco Majestouch II Ninja Tenkeyless Fortron BlueStorm II 500w CM 690II Advanced Razer DeathAdder 
Mouse PadAudioAudio
generic Echo Miamidi PCI M-Audio BX5a Studio Monitors 
  hide details  
Reply
post #5 of 11
Yea pretty much. There isnt much you cant do with bash really. Hell I wrote some code a while back to interface with an API via bash.. technically bash was never designed to do such things but I figured hell why not? So i gave it a try, and it worked.. In case you are curious:

Article I wrote with it:
http://www.h1tman.com/2010/09/cloudfiles-curl-example/

Code:
Quote:
#!/bin/bash
#
# File: cf-list.sh
#
# Written by: Tim Galyean
# Date: 8/4/2010
#
##################################################

USER="${1}"
APIKEY="${2}"
DEBUG="${3}"
LOG="cflist.log"

function f_exec() {
if [ "${DEBUG}" = "1" ]; then
# setting debug to 1 allows you to see full HTTP headers
# using this option will redirect the output to cflist.log
echo "redirecting verbose output to ${LOG}"
CURL="curl -v -H"
f_grabauthtoken 2>&1 > ${LOG}
f_list 1>>${LOG} 2>&1

# this url can be used to parse your containers and their contents
# Example: curl -s -H "X-Auth-Token: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX" <container URL>/<container>
echo "curl -s -H \\"X-Auth-Token: ${STORAGETOKEN}\\" $STORAGEURL"
else
# without using debug this script will just print your containers to stdout
CURL="curl -s -H"
f_grabauthtoken
f_list
fi
}

# Grab API Authentication Token, and Storage URL
function f_grabauthtoken() {
# Establish initial authentication
${CURL} "X-Auth-User: ${USER}" -H "X-Auth-Key: ${APIKEY}" https://auth.api.rackspacecloud.com/v1.0 2>&1 | grep Storage | awk -F'<' '{print $2}'

# Parse storage token to be used as an authentication key
STORAGETOKEN=`curl -v -H "X-Auth-User: ${USER}" -H "X-Auth-Key: ${APIKEY}" https://auth.api.rackspacecloud.com/v1.0 2>&1 | \\
grep Storage | awk -F'<' '{print $2}' | grep Token | awk '{print $2}' | tr -d '\
'`

# Parse the storage URL which will be the location of your containers
STORAGEURL=`curl -v -H "X-Auth-User: ${USER}" -H "X-Auth-Key: ${APIKEY}" https://auth.api.rackspacecloud.com/v1.0 2>&1 | \\
grep Storage | awk -F'<' '{print $2}' | grep Url | awk '{print $2}'`

}

# List Containers
function f_list() {
if [ -n ${STORAGETOKEN} ]; then
# This sends the API your token and storage url
# the API will return your container listing
${CURL} "X-Auth-Token: ${STORAGETOKEN}" $STORAGEURL
else
echo "Please authenticate first"
fi
}

# Usage instructions
function f_verify() {
# basic usage instructions
# to enable debugging use: ./cf-list.sh <username> <apikey> 1
if [ -z "${USER}" ] || [ -z "${APIKEY}" ]; then
echo "Usage: ./cf-list.sh <username> <apikey>"
else
f_exec
fi
}

f_verify
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
post #6 of 11
Thread Starter 
well usually people start off with command line with a few simple commands...

ls -la
cd dir
cd ..
mkdir dir
more textname


but they dont know it can get more complex with the same commands im kinda the same way and still learning, been jumping around the file system a lot looking at system files and config files and all sorts of stuff and so typing cd .. to go up one directory each time was kinda a pain... i figured out pretty quickly you can do cd ../nextdir and keep moving quicker and cd ../.. to jump up two

also another one is piping ls -laF through more ls -laF | more is very useful when searching through very full directories like etc if you are browsing for something but have no clue what it might be named
Kinda meh now...
(13 items)
 
  
CPUMotherboardGraphicsRAM
PhII 940 BE asus M4N82 Deluxe 2x 8800gts(g92) 2x 1g ocz ddr2 1066 
Hard DriveOptical DriveOSMonitor
/dev/sd[abc] /dev/sr0 WinXP/Linux 22in acer 
PowerCaseMouseMouse Pad
950w rosewill timebomb Antec 900 (2small) Voodoo Deathadder (RED!) X-Trac Pads Ripper XL 
  hide details  
Reply
Kinda meh now...
(13 items)
 
  
CPUMotherboardGraphicsRAM
PhII 940 BE asus M4N82 Deluxe 2x 8800gts(g92) 2x 1g ocz ddr2 1066 
Hard DriveOptical DriveOSMonitor
/dev/sd[abc] /dev/sr0 WinXP/Linux 22in acer 
PowerCaseMouseMouse Pad
950w rosewill timebomb Antec 900 (2small) Voodoo Deathadder (RED!) X-Trac Pads Ripper XL 
  hide details  
Reply
post #7 of 11
lol I knew all of this. =P good ol' cli
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
post #8 of 11
cls to clear screen
Its personal
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-4690k Asus Z97-A Sapphire Nitro R9 390 8GB with Backplate 16GB (4 x 4GB) Crucial DDR3 1600Mhz 
Hard DriveHard DriveOSMonitor
Crucial M500 240GB SSD Seagate 2TB SSHD Windows 10 Professional AOC Q2778VQE 27" 1440p 
KeyboardPowerCaseMouse
CM Storm Mech EVGA SuperNova 750G2 Fractal Design Define S Steel Series Rival 100 
  hide details  
Reply
Its personal
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-4690k Asus Z97-A Sapphire Nitro R9 390 8GB with Backplate 16GB (4 x 4GB) Crucial DDR3 1600Mhz 
Hard DriveHard DriveOSMonitor
Crucial M500 240GB SSD Seagate 2TB SSHD Windows 10 Professional AOC Q2778VQE 27" 1440p 
KeyboardPowerCaseMouse
CM Storm Mech EVGA SuperNova 750G2 Fractal Design Define S Steel Series Rival 100 
  hide details  
Reply
post #9 of 11
Quote:
Originally Posted by Jras View Post
cls to clear screen
Depends on the distro:

Code:
mrshroom@173-18-215-75:~/UrbanTerror$ cls
bash: cls: command not found
mrshroom@173-18-215-75:~/UrbanTerror$
clear works though, I'd show that but there is nothing to show. =P
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
post #10 of 11
Quote:
Originally Posted by Jras View Post
cls to clear screen
clear for *buntu, prolly debian as well, i believe it works in slackware too.
Bazinga Punk
(12 items)
 
ooh shiny!
(12 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveHard DriveOSMonitor
250gb Samsung Evo 850 250gb Samsung Evo 850 Windows 10 Samsung 43" 4k MU6300 
KeyboardPowerCaseMouse
Logitech Orion Spark 750w corsair Corsair 230T (Orange) Logitech G700 
  hide details  
Reply
Bazinga Punk
(12 items)
 
ooh shiny!
(12 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveHard DriveOSMonitor
250gb Samsung Evo 850 250gb Samsung Evo 850 Windows 10 Samsung 43" 4k MU6300 
KeyboardPowerCaseMouse
Logitech Orion Spark 750w corsair Corsair 230T (Orange) Logitech G700 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Useful cmd line thing i noticed