#
cmd1 && cmd2
cmd1 || cmd2
cmd1; cmd2
cmd1 & cmd2
clear
man
Ctrl+C
Ctrl+Z
Ctrl+W
Ctrl+U
Ctrl+R
exit Ctrl+D
cmd+up
cmd+down
ctrl+_
ctrl+t
ALT+t
ALT+.
ctrl+x+*
ctrl+arrow
ALT+f
ALT+b
ctrl+x+ctrl+e
ctrl+xx
ctrl+k
ctrl+y
CTRL+L
CTRL+J
CTRL+M
CTRL+N
CTRL+O
CTRL+P
CTRL+S
CTRL+X
Ctrl+A
Ctrl+E
mkdir
cd
cd
pwd
cd -
sudo rm -r dir
sudo rm -rf dir
cp -r dir1 dir2
find filename dir Find files from root rirectory find / -name wordToFind* List files that match the reg. exp. from current folder find . -name wordToFInd
whereis filename
which filename
Step 1, write in the terminal: at ENTER ex --> at 16:45 or at 13:43 7/23/11 (to be more precise) or after a certain delay: at now +5 minutes (hours, days, weeks, months, years) Step 2: ENTER repeat step 2 as many times you need Step 3: CTRL D to close input atq = show a list of jobs waiting to be executed atrm = delete a job n. ex (delete job #42) --> atrm 42 sleep = pause between commands with ";" you can chain commands, ex: touch file; rm file you can make a pause between commands (minutes, hours, dys) ex --> touch file; sleep 10; rm file <-- 10 seconds
crontab
crontab -e
crontab -1
crontab -r
<Day of week (0-6, 0 = Sunday)>
47 15 * * * touch /home/bob/movies.txt
30 5 1-15 * *
0 0 * * 1,3,4
cp bigMovieFile.mp4 &
nohup: ignores the HUP signal when closing the console (process will still run if the terminal is closed)
nohup cp bigMovieFile.mp4
jobs
fg (process 1), f%2 (process 2) f%3, ...
bg
fg
fg 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 &
fg %+
fg %-
fg %N
fg %string
fg %?string
disown <PID|JID>
wait
fg n
sudo shutdown -P +60
sudo shutdown -P 1:00
sudo shutdown -c
echo "ls -l" | at 07:00
pgm > file python hello.py > output.txt
pgm < file
python hello.py < foo.txt
pgm >> file python hello.py >> output.txt
pgm1 | pgm2
<< tag
Note that file descriptor 0 is normally standard input, 1 is standard output, and 2 is standard error output.
|file
n>|file
<> file
n<>file
n >& m
n <& m
n>&
n<&
&>file
<&-
&-
n>&-
n<&-
python hello.py 2> error.log python hello.py 2>/dev/null
python hello.py 2>&1
python hello.py &>/dev/null
ssh user@host
ssh -p user@host
ssh-copy-id user@host
w
ping
whois
dig
dig -x
wget
ping host
wget -c file
whoami
passwd
finger Example: Display information about the user ch. Output will appear similar to the following: finger -p ch Login name: admin In real life: Computer Hope On since Feb 11 23:37:16 on pts/7 from domain.computerhope.com 28 seconds Idle Time Unread mail since Mon Feb 12 00:22:52 2001
last
Definition The user and group quotas provide the mechanisms by which the amount of space used by a single user or all users within a specific group can be limited to a value defined by the administrator. - Soft Limit โ If the user exceeds the limit defined, there is a grace period that allows the user to free up some space. - Hard Limit โ When the hard limit is reached, regardless of the grace period, no further files or blocks can be allocated.
quota
edquota
quotacheck
setquota
quotaon
quotaoff
repquota
who
sudo adduser bob
sudo passwd
sudo deluser
addgroup friends
delgroup friends
usermod -g friends
usermod -g bob boby
usermod -aG friends bob
uname -a
cat /proc/cpuinfo
cat /proc/meminfo
free
ps -u yourusername
killall
top
echo $$
echo $!
kill -l
kill
ps -a
trap cmd sig1 sig2
trap "" sig1 sig2
trap - sig1 sig2
ps
ps aux --sort -rss
top
ps -e
killall UnResponsiveProg
Kill all processes matching the string "unresponsiveprog" (ignoring the difference between upper- ## lowercase letters)
killall -I unresponsiveprog
kill -9
tload
htop
Ctrl + z Then bg
fg
date
uptime
cal
uptime
calendar
ex: 12-Mar-2004 date +%d-%b-%Y today=$(date +%d-%b-%Y) && echo $today If it's 9 am, then it will show 09 date โ+%Hโ
whereis app
which app
grep -P '("|/)\S+/\S+' setup.sh
sudo %program% sudo program -l
sudo apt-get remove <application_name>
sudo apt-get install ex sudo apt-get install aptitude
sudo dpkg --install ex sudo dpkg --install megasync-xUbuntu_17.04_amd64.deb
(or bz2) - โCompiling from sourceโ Step 1, create a folder to place the file: mkdir /home/username/src <-- then cd to it Step 2, with 'ls' verify that the file is there (if not, mv ../file.tar.gz /home/username/src/) Step 3, decompress the file (if .zip: unzip ) Step 4, use 'ls', you should see a new directory Step 5, cd to the new directory Step 6.1, use ls to verify you have an INSTALL file, then: more INSTALL If you don't have an INSTALL file: Step 6.2, execute./configure <-- creates a makefile Step 6.2.1, run make <-- builds application binaries Step 6.2.2 : switch to root --> su Step 6.2.3 : make install <-- installs the software Step 7, read the readme file
./configure make make install install a package (Debian) dpkg -i pkg.deb install a package (RPM) rpm -Uvh pkg.rpm
sudo shutdown -h now
sudo shutdown -r now
sudo apt-get update sudo apt-get -y upgrade sudo apt-get update && sudo apt-get upgrade
sudo apt-get autoclean sudo apt-get clean sudo apt-get autoremove sudo apt autoremove && sudo apt clean
Alt + F2, type xkill
sudo ufw enable
sudo ufw disable
sudo apt install gufw
systemd-inhibit
systemd-inhibit myProgram
du -h
du -ah
du -sh
quota -v
du du -s
df
du The -h option makes the output easier to comprehend du -h /etc
df -k
history
shopt -s histverify
!$
!*
!-n
!n
!
!! sudo !!
!!:s///
!!:gs///
!$:t
!$:h Note: !! and !$ can be replaced with any valid expansion.
!!:n
!^
!$
!!:n-m
!!:n-$ !! can be replaced with any valid expansion i.e. !cat, !-2, !42, etc.
ctrl+r search_term
The default order for command lookup is functions, followed by built-ins, with scripts and executables last.
There are three built-ins that you can use to override this order: command
, builtin
and enable
.
removes alias and function lookup. Only built-ins and commands found in the search path are executed
command
builtin
enable
eval
cd; nano .bash_profile
alias gentlenode='ssh [email protected] -p 3404' # add your alias in .bash_profile Using alias to fix typos alias gerp=grep
cd; nano .bashrc
shopt -s cdable_vars export websites="/Users/mac/Documents/websites" source .bashrc cd websites