REFERENCE:
Webmin Installation:https://www.tecmint.com/install-webmin-on-ubuntu/
NOTE: after installation login with your username/root and terminal password.
Difference between apt Vs apt-get:
Main diff is apt-get uses in 2016 versions of Linux and apt is newer version.
Apt shows dependencies which are required to be upgrade and apt-get don’t.
COMMANDS
update and upgrade software: sudo apt update && upgrade
1. +tab: create auto when you write half letters of the dir/file/commands
Example: cd Des+tab it will auto write cd Desktop.
Example: ls+tab shows all commands which are using “ls” keywords.
2. Chmod:
0=No permission
1=x
2=w
3=xw
4=r
5=rx
6=rw
7=rwx
Give permission: chmod 777 filename OR chmod u=rwx,g=r,o= filename
Modify permission: chmod u+rwx,g+rwx,o+rwxc
Remove permission: chmod 000 filename OR chmod u-rwx, g-rwx, o-wrx filename
3. umask: If want to change permission (which are default when created file/dir). use 0000
Example: umask 0022. First 0 is by default and second zero means user have xrw permission and
group/other have rx permission in dir, just USER:0-7=7 GROUP:OTHER:7-2=5 which rx for group
and other in dir.
Default Dir umask is 0775
Now Dir umask is 114
Because 7-6=1 for u and g
5-2=3 for other.
For file it subtract with 666 because by default linux nerver give execute permission to a file
because file may be contain viruses. So user have rw permission and group/other have r permission.
Default File umask is 664
4. Chown: Change the ownership.
Example: chown umair file.txt.
5. open/xdg-open: Open any file/dir GUI (open command maybe only applicable for ubuntu
22.04).
6. Alias: convert long command into short.
Example: alias dir="ls -l | awk '{print \$9}'"
7. file: give file type
8. wc: use to show file line word and characters
NOTE: First will be a line, second will be a word and last will be a character
l: line
w: word
c: character
9. pwd: reveals current path.
10. cd -: go to the last directory you were in and reveals the path.
11. >: print/store command’s output. But it overwrite a text you can also use >> which append
a text.
12. tac:
13. tr:
14. fmt:
15. nl:
16. strace:
17. dtrace:
18. ftrace:
19. copy splits file content: cat file1 file2 > file3
20. split combined file: split -l 1(how many lines) file3
21. cal: shows calendar
22. date: shows date
23. ln: It create link between files. There are two type of link 1)Hard and 2) soft links.
Hard link: It creates replica of a file.
Example: ln file.txt file_ln.txt.
Soft link: It creates shortcut of a file.
Example: ln -s file.txt file_ln.txt.
NOTE: soft link will not work if original will delete.
24. touch: To make files
25. mkdir -p: To make directories inside directories
26. Rename dir: mv -T current_name new_name
27. rm: Remove files -rf is used when dir/file is not delete.
NOTE: r means recursive means it will also perform in sub dir as well.
28. rmdir: Remove dir
29. cp: copy file and dir.
Example: cp test.txt /home/umair/Desktop
30. mv: Move file and dir
Example: mv text /home/umair/Desktop
31. history: Show all commands which were previously fired.
32. man: Manual to show which short key is use for that command
Example: man uname
33. ls -la: listing with permission and all file (which are hide show as .)
l: show permission:
a: show hide file which start dot.
COMPRESSING FILE:
34. Tar:
35. gzip:
36. gunzip:
37. compress:
38. uncompress:
PRINT FILE:
39. cat: shows text inside a file. And -n shows text inside a file with numbers.
40. echo: print a file in terminal.
41. sort: print file in a sort form -n for -u for unique etc.
42. uniq: only print unique values.
43. head or head -50: shows start 10 lines
44. tail or tail -20: shows last 10 lines
45. sed: Help to print range in a file.
sed -n ‘num1p,num2p’ file_name
46. cut: Cut any character or word from any file or command.
-c: cut character. ‘-’ use for range and ‘,’ use for particular character number.
-f: cut by field (we can not use this option without range)
-d: define the range etc . , space or anything.
47. aw
k:
Advance of cut command when there are many spaces cut can not perform task.
Syntax: awk ‘{print $column_number1,$column_number2}’
NOTE: Work only for spaces.
Syntax: awk -F’:’ ‘{print $column_number1,$column_number2}’
F: for range
48. les
s:
Display file content page by page.
49. more: Display file content page by page.
NOTE: To go to next page press space and want to line by line press enter.
NOTE: The main difference is that less can go previous page(just press upper arrow key) where as
more can not.
50. zgrep: Print patterns inside a zip file.
51. grep(Global regular expression print): find a text in a file & print it.
^ (means beginning in every command): will print beginning patterns only.
grep “^umair khan” /etc/passwd
$ (means ending in every command): will print end patterns only.
-i: ignore case sensitive
-w: print exact word
-n (number): print line number
-c (count): print total line number in the form of number.
-v (invert match): print unmatched pattern.
-o: print that word only.
-A2: print 2 lines after matched patterns.
-b2: // // before 2 lines
-C2: print 2 lines before and after matched patterns.
-R/rgrep (Recursive): If you do not know exact path.
-E/egrep (Extended): Grep can not pint multiple patterns at the same time. Egrep is use
for that. OR
egrep ‘name1|name2|name3’ path.
NOTE: if use -E in grep command, It will perform as egrep.
NETWORK:
52. ifconfig: Interface-configuration, to check device name and change the configuration of a
device.
ifconfig down/up: if want to down/up any device
Example: ifconfig docker0 down
Change ip/net-mask/broadcast: ifconfig device_name IP/net mask/broadcast
Example: ifconfig docker0 192.168.0.1
Example: ifconfig docker0 netmask/broadcast 255.255.255.255
NOTE: Want to change all using single command
Example: ifconfig docker0 192.168.0.1 netmask 255.255.255.255 broadcast 192.168.42.255
ether: It's show mac address of the device. If want to change it.
Example: ifconfig docker0 hw ether AA:1F:0A:DD:FE
hw: hardware
NOTE: you can give multiple alias IP to a device using docker0:0 and so on.…
53. Dig:
54. ping:
55. iptable:
56. netstat: shows all current network connections
57. nslookup: Use to detail about domain and DNS records.
58. nmap:
59. tcpdump:
60. mtr:
61. traceroute:
62. dig airman:
63. airodump:
PROCESSES:
64. ps: Shows current processes
65. top: Shows all processes
66. Htop:
67. atop:
68. lsof: List of output file. It is use to find out which file is open or which file is dependent to
whom.
lsof -u user_name | more for particular user. -i for network only -i 4 and -i 6 for ipv4 or
ipv6 only.
A memory-mapped file contains the contents of a file in virtual memory.
File descriptor
Current working dir
Memory mapping files
Inode number of dir
Link/path
Read and write
Read
Write
First in first out
NOTE: press f after command will show all shorts forms with their full name.
69. kill: kill processes
NOTE: If process not is not killing use -9.
Example: kill -9 2424
SYSTEMS:
70. Go to server using ip: ssh name@ip then password.
Example: ssh root@206.130.120.44 pK&FgL347@0r
71. cpu: lscpu
72. uname: Shows system information.
73. ram: free -h
74. disk: lsblk
75. sudo cat /etc/shadow: Shows all user’s password in encrypted form.
76. cat
Encrypted password
Users
/etc/passwd: Shows all user’s.
Search user umair: grep umair /etc/passwd
GECOS or the full name of the user. This field contains a list of comma-separated values with the
following information:
User’s full name or the application name.
Room number.
Work phone number.
Home phone number.
Other contact information.
77. list all hardware: lshw
78. ios release and version: cat etc/os-release
79. whoami: show user name.
80. last: show all logins.
81. hostname: show machine host name
82. hostnamectl set-hostname new_name: Change hostname.
83. df -h: Use to show partition size and how much it is used and which dir it is mount
84. du -h: Use to show all file/dir size
85. nmon: Shows all detail about system in one click.
86. iostat:
87. sar:
SEARCH COMMANDS:
88. whereis: find path of a file
89. which: searches current $PATH for executable
90. Find: to find file or dir etc.
Example: find / -type f -name umair.txt Or find / -type d -name umair.txt
NOTE: iname use to find case sensitive and type d means directory only and f is for file.
If don't know exact name.
find / -type f -iname "*.php"
91. Locate: same as find command but fast.
Example: locate -ic umair.txt
i: shows only case sensitive file dir
c: count how many files are.
NOTE: It uses updatedb to search file/dir. When you create or delete file you should run updatedb
command.