#echo
Print text
echo textecho "Hello"Print a line
echo $HOMEPrint a variable
echo "new line" >> notes.txtAppend to a file
echoPrint text
echo textecho "Hello"Print a line
echo $HOMEPrint a variable
echo "new line" >> notes.txtAppend to a file
manRead the manual
man commandman tarThe full manual for tar (q to quit)
tar --helpA shorter summary
man -k "copy files"Search the manuals
clearClear the screen
clearclearSame as pressing Ctrl+L
aliasMake your own shortcut
alias name='command'alias ll='ls -lah'Now ll does the long list
aliasShow your aliases
exportSet an environment variable
export NAME=valueexport EDITOR=nanoUse nano as your default editor in this session
export PATH="$PATH:$HOME/bin"Add a folder to the program search path
sourceRun a file in the current shell
source filesource ~/.bashrcReload your shell settings
redirects and pipesConnect commands
> >> < | 2>ls > list.txtWrite output to a file (replaces it)
ls >> list.txtAppend instead
command 2> errors.txtSave only the error messages
command > all.txt 2>&1Save output and errors together
ps aux | grep sshPipe the output of one command into another
for / ifLoops and tests
for x in list; do ...; donefor f in *.jpg; do echo "$f"; doneDo something for every jpg
if [ -f notes.txt ]; then echo yes; fiTest whether a file exists
for h in web1 web2; do ssh $h uptime; doneRun uptime on two servers
bash scriptYour first script
#!/bin/bashnano hello.shCreate the file with #!/bin/bash on the first line, then: echo "Hello"
chmod +x hello.shMake it runnable
./hello.shRun it
watchRepeat a command
watch [-n seconds] commandwatch -n 2 df -hRefresh every two seconds
timeMeasure how long it takes
time commandtime ./backup.shPrints real, user and system time
sleepWait
sleep secondssleep 5Pause five seconds
exitLeave the shell or SSH session
exitexitLog out (Ctrl+D does the same)
SSH Command is a desktop app for Mac, Windows and Linux that puts a real terminal, SFTP file panes, a sudo switch and a searchable Linux command finder in one window. Type what you want to do, and send the command to your server with one click.
Download free Windows commands with examples SFTP & FTP client