x32x01
ADMINISTRATOR
- by x32x01 ||
Linux is becoming well known because it’s more than just free software as it’s unusually a good operating system. Linux was first developed by Linus Torvalds at the University of Helsinki in Finland.
If you’ve never worked with Linux before, you may be confused as to why there are so many different versions of it available. Linux commands are not the same as standard Unix ones. Most of the commands are provided by the GNU project.
Back before the days of graphical desktops, the only way to interact with a Unix system was through a text command line interface (CLI) provided by the shell. The CLI allowed text input only, and could only display text and rudimentary graphics output.
If you’re just beginning to work on a Linux system in this year (2020), the abundance of commands might prove daunting. To help, the following lists present a sampling of commands on various topics such as Networking, File Management, Programming etc.
If you’ve never worked with Linux before, you may be confused as to why there are so many different versions of it available. Linux commands are not the same as standard Unix ones. Most of the commands are provided by the GNU project.
If you’re just beginning to work on a Linux system in this year (2020), the abundance of commands might prove daunting. To help, the following lists present a sampling of commands on various topics such as Networking, File Management, Programming etc.
S.No | Commands | Description |
---|---|---|
1 | uname -a | Display Linux system information |
2 | uname -r | Display kernel release information |
3 | cat /etc/redhat-release | Show which version of redhat installed |
4 | uptime | Show how long the system has been running + load |
5 | hostname | Show system host name |
6 | hostname -I | Display the IP addresses of the host |
7 | last reboot | Show system reboot history |
8 | date | Show the current date and time |
9 | cal | Show this month’s calendar |
10 | w | Display who is online |
11 | whoami | Who you are logged in as |
12 | dmesg | Display messages in kernel ring buffer |
13 | cat /proc/cpuinfo | Display CPU information |
14 | cat /proc/meminfo | Display memory information |
15 | free -h | Display free and used memory ( -h for human readable, -m for MB, -g for GB.) |
16 | lspci -tv | Display PCI devices |
17 | lsusb -tv | Display USB devices |
18 | dmidecode | Display DMI/SMBIOS (hardware info) from the BIOS |
19 | hdparm -i /dev/sda | Show info about disk sda |
20 | hdparm -tT /dev/sda | Perform a read speed test on disk sda |
21 | badblocks -s /dev/sda | Test for unreadable blocks on disk sda |
22 | top | Display and manage the top processes |
23 | htop | Interactive process viewer (top alternative) |
24 | mpstat 1 | Display processor related statistics |
25 | vmstat 1 | Display virtual memory statistics |
26 | iostat 1 | Display I/O statistics |
27 | tail 100 /var/log/messages | Display the last 100 syslog messages (Use /var/log/syslog for Debian based systems.) |
28 | tcpdump -i eth0 | Capture and display all packets on interface eth0 |
29 | tcpdump -i eth0 ‘port 80’ | Monitor all traffic on port 80 ( HTTP ) |
30 | lsof | List all open files on the system |
31 | lsof -u user | List files opened by user |
32 | free -h | Display free and used memory ( -h for human readable, -m for MB, -g for GB.) |
33 | watch df -h | Execute “df -h”, showing periodic updates |
34 | id | Display the user and group ids of your current user. |
35 | last | Display the last users who have logged onto the system. |
36 | who | Show who is logged into the system. |
37 | w | Show who is logged in and what they are doing. |
38 | groupadd test | Create a group named “test”. |
39 | useradd -c “John Smith” -m john | Create an account named john, with a comment of “John Smith” and create the user’s home directory. |
40 | userdel john | Delete the john account. |
41 | usermod -aG sales john | Add the john account to the sales group |
42 | ls -al | List all files in a long listing (detailed) format |
43 | pwd | Display the present working directory |
44 | mkdir directory | Create a directory |
45 | rm file | Remove (delete) file |
46 | rm -r directory | Remove the directory and its contents recursively |
47 | rm -f file | Force removal of file without prompting for confirmation |
48 | rm -rf directory | Forcefully remove directory recursively |
49 | cp file1 file2 | Copy file1 to file2 |
50 | cp -r source_directory destination | Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with the contents of source_directory. |
51 | mv file1 file2 | Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2 |
52 | ln -s /path/to/file linkname | Create symbolic link to linkname |
53 | touch file | Create an empty file or update the access and modification times of file. |
54 | cat file | View the contents of file |
55 | less file | Browse through a text file |
56 | head file | Display the first 10 lines of file |
57 | tail file | Display the last 10 lines of file |
58 | tail -f file | Display the last 10 lines of file and “follow” the file as it grows. |
59 | ps | Display your currently running processes |
60 | ps -ef | Display all the currently running processes on the system. |
61 | ps -ef | grep processname | Display process information for processname |
62 | top | Display and manage the top processes |
63 | htop | Interactive process viewer (top alternative) |
64 | kill pid | Kill process with process ID of pid |
65 | killall processname | Kill all processes named processname |
66 | program & | Start program in the background |
67 | bg | Display stopped or background jobs |
68 | fg | Brings the most recent background job to foreground |
69 | fg n | Brings job n to the foreground |
70 | ifconfig -a | Display all network interfaces and ip address |
71 | ifconfig eth0 | Display eth0 address and details |
72 | ethtool eth0 | Query or control network driver and hardware settings |
73 | ping host | Send ICMP echo request to host |
74 | whois domain | Display whois information for domain |
75 | dig domain | Display DNS information for domain |
76 | dig -x IP_ADDRESS | Reverse lookup of IP_ADDRESS |
77 | host domain | Display DNS ip address for domain |
78 | hostname -i | Display the network address of the host name. |
79 | hostname -I | Display all local ip addresses |
80 | wget http:// domain .com/file | Download http:// domain .com/file |
81 | netstat -nutlp | Display listening tcp and udp ports and corresponding programs |
82 | tar cf archive.tar directory | Create tar named archive.tar containing directory. |
83 | tar xf archive.tar | Extract the contents from archive.tar. |
84 | tar czf archive.tar.gz directory | Create a gzip compressed tar file name archive.tar.gz. |
85 | tar xzf archive.tar.gz | Extract a gzip compressed tar file. |
86 | tar cjf archive.tar.bz2 directory | Create a tar file with bzip2 compression |
87 | tar xjf archive.tar.bz2 | Extract a bzip2 compressed tar file. |
88 | yum search keyword | Search for a package by keyword. |
89 | yum install package | Install package. |
90 | yum info package | Display description and summary information about package. |
91 | rpm -i package.rpm | Install package from local file named package.rpm |
92 | yum remove package | Remove/uninstall package. |
93 | tar zxvf sourcecode.tar.gz cd sourcecode ./configure make make install | Install software from source code. |
94 | grep pattern file | Search for pattern in file |
95 | grep -r pattern directory | Search recursively for pattern in directory |
96 | locate name | Find files and directories by name |
97 | find /home/john -name ‘prefix*’ | Find files in /home/john that start with “prefix”. |
98 | find /home -size +100M | Find files larger than 100MB in /home |
99 | ssh host | Connect to host as your local username. |
100 | ssh user@host | Connect to host as user |
101 | ssh -p port user@host | Connect to host using port |
102 | scp file.txt server:/tmp | Secure copy file.txt to the /tmp folder on server |
103 | scp server:/var/www/*.html /tmp | Copy *.html files from server to the local /tmp folder. |
104 | scp -r server:/var/www /tmp | Copy all files and directories recursively from server to the current system’s /tmp folder. |
105 | rsync -a /home /backups/ | Synchronize /home to /backups/home |
106 | df -h | Show free and used space on mounted filesystems |
107 | df -i | Show free and used inodes on mounted filesystems |
108 | fdisk -l | Display disks partitions sizes and types |
109 | du -ah | Display disk usage for all files and directories in human readable format |
110 | du -sh | Display total disk usage off the current directory |
111 | cd .. | To go up one level of the directory tree. (Change into the parent directory.) |
112 | cd | Go to the $HOME directory |
113 | cd /etc | Change to the /etc directory |