Ten Useful Commands in Linux

That the power of Linux lies in its command line is an oft repeated statement and newbies need to be introduced to it. This article lists the top 10 commands in Linux.

Graphical user interfaces (GUIs) are helpful for many tasks, but they are not good for all purposes. Computers were supposed to free us from manual labour, but how often have you performed some task that you felt sure the computer ought to be able to do, instead of you tediously working the mouse. Pointing and clicking, pointing and clicking.

The Linux GUI runs on the shell. When the GUI is not running, the shell is  Linux is running. But if the shell is not running, nothing is. Commands in Linux are a means of interacting with the shell.

Here are the top 10 commands for systems and network administration.

Figure 1: The uptime command shows how long the system has been running

1. The uptime command

In Linux, the uptime command shows since when your system has been running, the number of users that are currently logged in and also displays the load average for 1, 5 and 15 minute intervals.

Figure 2: The who command prints information about the users who are currently logged in

2. The who command

The who command returns the user name, date, time and host information.

Figure 3: SSH connects and logs into the specified hostname. Users must prove their identity to the remote machine

3. The SSH command

The secure shell (SSH) command is used to log in to the remote host. The SSH client is a program for logging into and executing commands on a remote machine. It provides secure encrypted communications between two untrusted hosts over an insecure network.

Figure 4: The program allows a user to transfer files to and from a remote network site

4. The Ftp or sftp commands

Ftp or sftp commands are used to connect to a remote ftp host. Ftp is (file transfer protocol) and sftp is (secure file transfer protocol). For example, the command in Figure 4 will connect to the ftp host (192.168.50.2).

Figure 5: The free command shows the free, total and swap memory information in bytes

5. The free command

Free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The shared memory column represents either the MemShared value or the Shmem value taken from the /proc/meminfo file. The value is zero if none of the entries is exported by the kernel.

Figure 6: The top command displays the processor activity of your system as well as the tasks managed by the kernel, in real-time

6. The top command

The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel. The kind of information shown, as well as the types, order and volume of information displayed for processes, is all user-configurable; and that configuration can be made persistent across restarts.

Figure 7: The Isof command displays a list of all open files

7. The lsof command

Lsof revision 4.86 lists, on its standard output file, information about files opened by processes for the following UNIX dialects:

Apple Darwin 9 and Mac OS X 10 [567]

FreeBSD 4.9 and 6.4 for x86-based systems

FreeBSD 8.2, 9.0 and 10.0 for AMD64-based systems

Linux 2.1.72 and above for x86-based systems

Solaris 9, 10 and 11

An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket). Instead of a formatted display, lsof will produce output that can be parsed by other programs. In addition to producing a single output list, lsof will run in repeat mode, during which it will produce output, delay, then repeat the output operation until stopped with an interrupt or quit signal.

Figure 8: The pwd command returns the current working directory

8. The pwd command

This prints the full file name of the current working directory.

Figure 9: Using the ‘i’ option to get confirmation before removing it

9. The rm command

The rm command removes each specified file. By default, it does not remove directories. If the -i or –interactive=once option is given, and there are more than three files, then rm asks the user whether to proceed with the entire operation. If the response is not in the affirmative, the entire command is aborted. Using options -r and -f will remove the file forcefully without confirmation.

Figure 10: Starting, restarting Apache2 server on Ubuntu

10. The service command

The service command controls the starting, stopping or restarting of a service. This command makes it possible to start, restart or stop a service without restarting the system, for the changes to take effect.