Whatbox Logo

Wiki > Bash Shell Commands

Legend

Everything in "<>" is to be replaced. Example: <filename> --> whatbox.txt
'..' means that more than one file can be affected with only one command.

Basic Terminal Shortcuts

Ctrl L Clear the terminal
Ctrl D Logout
Ctrl A Move the cursor to the beginning of the line
Ctrl E Move the cursor to the end of the line
Ctrl U Delete left of the cursor
Ctrl K Delete right of the cursor
Ctrl W Delete the word to the left of the cursor
Ctrl Y Paste (after Ctrl U, K, or W)
Ctrl R Reverse search history
Ctrl Z Suspend a process to resume it later !! Repeat the last command used
Shift PageUp Scroll up in the terminal
Shift PageDown Scroll down in the terminal
Alt . Copy the last argument of the previous command

Basic Terminal Navigation

ls -a List all files and folders
ls <foldername> List files in a folder
ls -lh Detailed list with a human-readable output
ls -l *.jpg List only jpeg files
ls -lh <fileName> Result for only a single file

cd <foldername> Change directory - If the folder name has spaces, use quotes. Example: cd "Folder With Spaces"
cd .. Go up one folder.
tip: ../../../
du -h Disk usage of folders in a human-readable output
du -ah Disk usage of files and folders in a human-readable output
du -sh Only show disk usage of folders

pwd Print the working directory

man <command> Shows the manual for a command or program

Basic file manipulation

cat <filename> Show the contents of a file (less, more)
head From the top
tail From the bottom

mkdir <foldername> Create a new folder
Example: mkdir stuff
Example: mkdir stuff/videos/ ..

cp image.jpg newimage.jpg Copy and rename a file
cp image.jpg <foldername>/ Copy to a folder
Example: cp image.jpg folder/image.jpg
cp -R folder1/ folder2/ Recursively (-R) copies folder1 and all of its contents into folder2.

mv file.txt documents/ Move a file to a folder
mv <folderName> <foldername2> Move a folder into a folder
mv filename.txt filename2.txt Rename a file
mv <foldername>/ .. Move a folder up in the hierarchy

touch <filename> Create or update a file

ln -s file1 file2 Symbolically link

More advanced tricks

Background a running process

If you start a process but need to close your terminal before it's completed, you may wish to background a process you're currently running. This can be achieved by executing the following three commands in sequence.

Ctrl Z
bg
disown -h

Ctrl Z Suspends the process bg resumes the process, but in the background disown -h tells it to ignore the hangup signal (nohup)

Changing the timezone

See Changing Your Bash Timezone