Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
Bash Shell Cheat SheetV2

Bash Shell Cheat SheetV2

Ratings: (0)|Views: 1|Likes:
Published by HIrak Chattopadhyay
Uploaded from Google Docs
Uploaded from Google Docs

More info:

Published by: HIrak Chattopadhyay on Apr 23, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/23/2012

pdf

text

original

 
Linux Bash ShellCheat Sheet
(works with about every distribution, except for apt-get which is Ubuntu/Debian exclusive)
Legend:Everything in “<>” is to be replaced, ex: <fileName> --> iLovePeanuts.txtDon't include the '=' in your commands'..' means that more than one file can be affected with only one command ex: rmfile.txt file2.txt movie.mov .. ..
 
Linux Bash Shell Cheat Sheet
Basic CommandsBasic Terminal ShortcutsBasic file manipulation
CTRL L = Clear the terminalcat <fileName> = show content of fileCTRL D = Logout(less, more)SHIFT Page Up/Down = Go up/down the terminalhead = from the topCTRL A = Cursor to start of line-n <#oflines> <fileName>CTRL E = Cursor the end of lineCTRL U = Delete left of the cursor tail = from the bottomCTRL K = Delete right of the cursor-n <#oflines> <fileName>CTRL W = Delete word on the leftCTRL Y = Paste (after CTRL U,K or W)mkdir = create new folderTAB = auto completion of file or commandmkdir myStuff ..CTRL R = reverse search historymkdir myStuff/pictures/ ..!! = repeat last command
CTRL Z = stops the current command (resume with fg in foreground or bg in background)
cp image.jpg newimage.jpg = copy and rename a file
Basic Terminal Navigation
cp image.jpg <folderName>/ = copy to foldercp image.jpg folder/sameImageNewName.jpgls -a = list all files and folderscp -R stuff otherStuff = copy and rename a folderls <folderName> = list files in foldercp *.txt stuff/ = copy all of *<file type> to folderls -lh = Detailed list, Human readablels -l *.jpg = list jpeg files onlymv file.txt Documents/ = move file to a folderls -lh <fileName> = Result for file onlymv <folderName> <folderName2> = move folder in
folder
mv filename.txt filename2.txt = rename filecd <folderName> = change directorymv <fileName> stuff/newfileNameif folder name has spaces use mv <folderName>/ .. = move folder up in hierarchycd / = go to rootcd .. = go up one folder, tip: ../../../rm <fileName> .. = delete file (s)rm -i <fileName> .. = ask for confirmation each filedu -h: Disk usage of folders, human readablerm -f <fileName> = force deletion of a filedu -ah: “ files & folders, Human readablerm -r <foldername>/ = delete folderdu -sh: only show disc usage of folderstouch <fileName> = create or update a filepwd = print working directoryln file1 file2 = physical linkman <command> = shows manual (RTFM)ln -s file1 file2 = symbolic link
 
Linux Bash Shell Cheat Sheet
Basic CommandsResearching FilesExtract, sort and filter data
The slow method (sometimes very slow):
grep <someText> <fileName> = search for text in file-i = Doesn't consider uppercase wordslocate <text> = search the content of all the files-I = exclude binary fileslocate <fileName> = search for a filegrep -r <text> <folderName>/ = search for file namessudo updatedb = update databaseof fileswith occurrence of the textfind = the best file search tool(fast)
With regular expressions:
 find -name “<fileName>”find -name “text” = search for files who start with the word textgrep -E ^<text> <fileName> = search start of linesfind -name *text= end with the word textgrep -E <0-4> <fileName> =
shows lines containing numbers 0-4
Advanced Search:
grep -E <a-zA-Z> <fileName> = retrieve all lineswith alphabetical lettersSearch from file Size (in ~)find ~ -size +10M = search files bigger than.. (M,K,G)sort = sort the content of filessort <fileName> = sort alphabeticallySearch from last accesssort -o <file> <outputFile> = write result to a filefind -name <filetype>-atime -5sort -r <fileName> = sort in reverse('-' = less than, '+' = more than and nothing = exactly)sort -R <fileName> = sort randomlysort -n <fileName> = sort numbersSearch only files or directory’sfind -type d --> ex: find /var/log -name "syslog" -type dwc = word countfind -type f= fileswc <fileName> = nbr of line, nbr of words, byte size-l (lines), -w (words), -c (byte size), -mMore info: man find, man locate(number of characters)cut = cut a part of a file-c --> ex: cut -c 2-5 names.txt(cut the characters 2 to 5 of each line)-d (delimiter) (-d & -f good for .csv files)-f (# of field to cut)more info: man cut, man sort, man grep

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->