Show Menu
Cheatography

Unix Cheatsheet Cheat Sheet by

Basic commands

pwd
Where am I in the system
ls [path]
List of given path. Common params -l -h -a
cd [path]
Change directory
~ (tilde)
Used in paths as a reference to your home directory (eg. ~/Docu­ments )
. (dot)
Used in paths as a reference to your current directory (eg. ./bin ).
.. (dot dot)
Used in paths as a reference to your current direct­ories parent directory (eg. ../bin ).
[KEY] TAB
Start typing and press TAB. The system will auto complete the path. Press TAB twice and it will show you your altern­atives.

File manipu­lation

mkdir <dir name>
create directory
rmdir <dir name>
remove empty directory
rm <pa­th>
remove file also non-empty folder with -f param (-r recurs­ively)
touch <file name>
create empty file
cp <so­urc­e> <de­sti­nat­ion>
copy source to destin­ation
mv <so­urc­e> <de­sti­nat­ion>
move source to destin­ation also used for rename

Files (+filters)

head
show the first n lines (-n)
tail
show the last n lines (-n)
sort
sort lines in a given way
wc
How many words, characters and lines.
grep
search for given patters

Wildcards - May be used anywhere in any path

*
Zero or more characters (eg. b*).
?
Single character (eg. file.???).
[]
Range (eg. b[aio]t).

Useful commands

du -sh [dir/file]
Disk usage (-s summary -h humman readable)
df -h
Display how much disk space is used and also free
find /home -mtime -1
Find all files in the given directory (and subdir­ect­ories) which have been modified in the last 24 hours.
shutdown -h now
Shutdown the system. (Replace -h with -r for reboot.)
reboot
Restart machine
date
Show the current date and time
whoami
who you are logged in as
finger <us­er>
display inform­ation about user
man <co­mma­nd>
show the manual for command
whereis <ap­p>
show possible location of app
which <ap­p>
show which app will be run by default
 

Persmi­ssions

r
read
w
write
x
execute
permission order
Owner(­user) Group Other
chmod <pe­rmi­ssi­ons> <pa­th>
hange permis­sions. Permis­sions can be either shorthand (eg. 754) or longhand (eg. g+x)

Piping and Redire­ction

>
Redirect STDOUT to a file.
>>
Redirect STDOUT to a end of file.
2>
Redirect the STDERR to a file.
<
Pass the contents of a file to a program as STDIN.
|
Feed the STDOUT of the program on the left as STDIN to the program on the right.

Apache

Config files virtual hosts
/etc/h­ttp­d/c­onf­/ht­tpd.conf
hostin­g.z­noj­mo.cz
/etc/h­ttp­d/c­onf.d/­vir­tua­ly.conf
Restart service gracefull
apachectl graceful
Restart service hard
sudo service apache2 restart
Log file
/var/l­og/­httpd
ispconfig specific
/var/w­ww/­web­1/log/
New virtual
web-uz­ivatel

MySQL

Config files
/etc/m­ysql/
 
/etc/m­ysq­l/c­onf.d/
Restart service
service mysql restart
 
service mysqld restart
 
/etc/i­nit.d/­mysqld restart
Status service
systemctl status mysql.s­­e­rvice
Log file
/var/l­og/­mys­ql/­err­or.log

Process management

CTRL + C
Cancel the currently running process
kill <pr­ocess id>
Cancel the given process. Include the option -9 to kill a stubborn process
ps
Obtain a listing of processes and their id's. Including the option aux will show all processes.
jobs
See a list of current processes in the backgr­ound.
CTRL+ Z
CTRL + Z Pause the currently running process and put it in the backgr­ound.
fg <job number>
Move the given process from the background to the foregr­ound.

Colabo­ration Required

Do you want help with this cheatsheet
           
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          tmux the terminal multiplexer Cheat Sheet
          Awesome Window Manager 3.x Cheat Sheet