Advanced Commands for Middle Level Linux Users
You might have found the first article very much useful and this article is an extension of the 20 Useful Linux Commands for all. Now It's time to show you some other very useful advanced Linux commands. In this article, we discussed the commands which a middle-level user requires to manage his own system.
head: Displaying the Beginning of a File
The head command, as the name implies, displays the top of the file. When used without any option, it displays the first 10 lines of the argument file. To specify line count and display, say, the first five lines. Use - symbol, followed by a numeric argument
$ head -5 server.log
head is often used with the grep command to restrict the display to a few lines.
$ grep "img src.*png" index.html | head -5
tail: Displaying the End of a File
Complementing its head counterpart, the tail command displays the end of the file. It provides an additional method of addressing lines, and like head, it displays the last 10 lines when used without arguments.
$ tail -3 server.log
ps: Process Status
The ps command is used to display the attributes of a process.
$ ps PID TTY TIME CMD 6373 pts/0 00:00:00 bash 11901 pts/0 00:00:00 ps
-u Displaying Processes of a User
-a Displaying all User Processes
-f Full Listing
who and w: Know the Users
There are two commands which display an informative listing of users- who and w. who produces a simple three-columnar output:
$ who linuxuser :0 2020-08-15 12:03 (:0)
The w command produces a more detailed output of users' activities.
date: Display the System Date
You can display the current date with date command.
The command can also be used with suitable format specifiers as arguments.
$ date +%m 15
or month name:
$ date +%h Aug
cal: The Calendar
cal is a handy tool that you can invoke anytime to see the calendar of any specific month or a complete year.
$ cal August 2020 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
To see the calendar for the month of December
$ cal -m dec
netstat: Displaying the Network Parameters
netstat command displays various network related information such as network connections, routing tables, etc...
List All Routing Table
$ netstat -rn
List All TCP Ports
$ netstat -at
ifconfig: Configuring the Network Interfaces
ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.
$ ifconfig docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:04:4b:c0:9d txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Set the IP address of your interface
$ ifconfig eth0 192.168.1.10
Enable/Disable an Interface
$ ifconfig eth0 up
$ ifconfig eth0 down