Unix Shell¶
Useful UNIX commands:¶
pwdpwd= print working directory (where am I now?)
lsls= list (what's in this directory?)ls -lah= list all files in human-readable form
cdcd(destination) = change directory to an absolute or relative destinationcd ~= go to user's home directorycd .= go to same directorycd ..= move up one directorycd -= go back to previous directory./= 'here'
historyhistory= see prior commands
cpcp(file to be copied) (destination) = copy file to a destinationcp -r(directory to be copied) (destination) = copy directory to a destination
mkdirmkdir(name of new directory) = make a new directory inside your current directory
mvmv(file to be moved) (destination) = move file to new destinationmv -r(directory to be moved) (destination) = move directory to a destinationmv(file/directory) (new name) = renames the file or directory
rmrm(file to be removed) = delete a filerm -r(directory to be removed) = delete a directory- THIS IS FOREVER, BE SURE YOU WANT TO
rmWHATEVER YOU ARErm-ING!!
nanonano(filename) = opensnanotext editor on the file specified. If file doesn't exist,nanowill create it- Use shortcut commands listed at bottom of
nanoscreen to save file or exit
**= wildcard, represents any number of any characters*.txt= any file ending with .txtabc*= any file that starts with abc*7*= any file that has a seven somewhere in the middle
??= represents any one characterfile?.txt= any file that starts with "file", has one character of any type, and ends with ".txt"
wcwc= word countwc -l= count number of lines- Check out
wc -hfor all available options
grepgrep= search a file for a patterngrepis very detailed, check outgrep -hfor usage
||= pipe, take the output of the last operation and use it as the input for the next operationgrep "lily" flowers.txt | wc -l= searches for occurrences of "lily" in the flowers.txt file and returns the number of lines