Linux Bash Shell Cheat Sheet
Basic Commands
Basic Terminal Shortcuts Basic file manipulation
CTRL L = Clear the terminal cat <fileName> = show content of file
CTRL D = Logout (less, more)
SHIFT Page Up/Down = Go up/down the terminal head = from the top
CTRL A = Cursor to start of line -n <#oflines> <fileName>
CTRL E = Cursor the end of line
CTRL U = Delete left of the cursor tail = from the bottom
CTRL K = Delete right of the cursor -n <#oflines> <fileName>
CTRL W = Delete word on the left
CTRL Y = Paste (after CTRL U,K or W) mkdir = create new folder
TAB = auto completion of file or command mkdir myStuff ..
CTRL R = reverse search history mkdir 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 folder
cp image.jpg folder/sameImageNewName.jpg
ls -a = list all files and folders cp -R stuff otherStuff = copy and rename a folder
ls <folderName> = list files in folder cp *.txt stuff/ = copy all of *<file type> to folder
ls -lh = Detailed list, Human readable
ls -l *.jpg = list jpeg files only mv file.txt Documents/ = move file to a folder
ls -lh <fileName> = Result for file only mv <folderName> <folderName2> = move folder in folder
mv filename.txt filename2.txt = rename file
cd <folderName> = change directory mv <fileName> stuff/newfileName
if folder name has spaces use “ “ mv <folderName>/ .. = move folder up in hierarchy
cd / = go to root
cd .. = go up one folder, tip: ../../../ rm <fileName> .. = delete file (s)
rm -i <fileName> .. = ask for confirmation each file
du -h: Disk usage of folders, human readable rm -f <fileName> = force deletion of a file
du -ah: “ “ “ files & folders, Human readable rm -r <foldername>/ = delete folder
du -sh: only show disc usage of folders
touch <fileName> = create or update a file
pwd = print working directory
ln file1 file2 = physical link
man <command> = shows manual (RTFM) ln -s file1 file2 = symbolic link
评论