GNU Bash or simply Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. Bash Cheat Sheet for UNIX Systems that might be helpful while you working on UNIX systems.
# To suspend a job, type CTRL+Z while it is running. You can also suspend a job with CTRL+Y.
# This is slightly different from CTRL+Z in that the process is only stopped when it attempts to read input from terminal.
# Of course, to interupt a job, type CTRL+C.
myCommand &
runs the job in the background and prompts back the shell
jobs
lists all jobs (use with -l to see associated PID)
fg
brings a background job into the foreground
fg %+
brings most recently invoked background job
fg %-
brings the second most recently invoked background job
fg %N
brings job number N
fg %string
brings a job whose command begins with the string
fg %?string
brings a job whose command contains the string
kill -l
returns a list of all signals on the system, by name and number
kill PID
terminates the process with specified PID
ps
prints a line of information about the current running login shell and any processes running under it
ps -a
selects all processes with a TTY except session leaders
trap cmd sig1 sig2
executes a command when a signal is received by the script
trap "" sig1 sig2
ignores that signals
trap - sig1 sig2
resets the action taken when the signal is received to the default
if you want to use bash (type exit to go back to your normal shell)
whereis bash
finds out where bash is on your system
clear
clears content on the window (hide displayed lines)
# File Commands.
ls
lists your files
ls -l
ists your files in ‘long format’, which contains the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified
ls -a
lists all files, including hidden files
ln -s <filename> <link>
creates a symbolic link to file
touch <filename>
creates or updates your file
cat > <filename>
places standard input into file
more <filename>
shows the first part of a file (move with space and type q to quit)
head <filename>
outputs the first 10 lines of a file
tail <filename>
outputs the last 10 lines of a file (useful with -f option)
emacs <filename>
lets you create and edit a file
mv <filename1> <filename2>
moves a file
cp <filename1> <filename2>
copies a file
rm <filename>
removes a file
diff <filename1> <filename2>
compares files, and shows where they differ
wc <filename>
tells you how many lines, words, and characters there are in the file
chmod -options <filename>
lets you change the read, write, and execute permissions on your files
gzip <filename>
compresses files
gunzip <filename>
uncompresses files compressed by gzip
gzcat <filename>
lets you look at gzipped file without actually having to gunzip it
lpr <filename>
print the file
lpq
check out the printer queue
lprm <jobnumber>
remove something from the printer queue
genscript
converts plain text files into postscript for printing and gives you some options for formatting
dvips <filename>
print .dvi files (i.e. files produced by LaTeX)
grep <pattern> <filenames>
looks for the string in the files
grep -r <pattern> <dir>
search recursively for a pattern in the directory
# Directory Commands.
mkdir <dirname>
makes a new directory
cd
changes to home
cd <dirname>
changes directory
pwd
tells you where you currently are
# SSH, System Info & Network Commands.
ssh user@host
connects to host as a user
ssh -p <port> user@host
connects to host on the specified port as user
ssh-copy-id user@host
adds your ssh key to host for a user to enable a keyed or passwordless login
whoami
returns your username
passwd
lets you change your password
quota -v
shows what your disk quota is
date
shows the current date and time
cal
shows the month’s calendar
uptime
shows current uptime
w
displays whois online
finger <user>
displays information about the user
uname -a
shows kernel information
man <command>
shows the manual for the specified command
df
shows disk usage
du <filename>
shows the disk usage of the files and directories in the filename (du -s give only a total)
last <yourUsername>
lists your last logins
ps -u yourusername
lists your processes
kill <PID>
kills (ends) the processes with the ID you gave
killall <processname>
kill all processes with the name
top
displays your currently active processes
bg
lists stopped or background jobs; resume a stopped job in the background