Warning icon

New location: Zurich, Switzerland

Commands of Linux: from Newbies to System Administrator (Part 1)

Commands of Linux: from Newbies to System Administrator (Part 1)
549

Learning of computer commands are not just for computer programmers alone. Command refers to any phrase, word, or symbol, etc that when inputted into a computer system, compels it to perform certain functions. The keyword here is “compel”. This is because just like a command given by senior military personnel to his junior counterparts, computer commands cannot be ignored, and immediately they are imputed into the system, begin to carry out the necessary instructions to display the intended output, hastily too. It is a directive that the computer operating system must obey.

Whatever your user experience as a Linux user, you ought to understand a few root commands of your Linux server. This makes it considerably easy for you to navigate your way around your server especially during emergency situations where you may find it difficult to elicit expert help. With these commands, you can arrange, organize, optimize, and troubleshoot your Linux server whenever you like. With the necessary computer command, you truly become the master and chief commander of your operating system.

These commands can come in handy when things go wrong and can be used to correct errors and find necessary information (especially the root commands). Newbie, or developer, these Linux root commands can be essential for most Linux server operators.

Why Commands are Important for System Admin

A system admin is almost always on the terminal. It is his second home (if not his first). So it is exceedingly important that he/she understands his way around the terminal. He must be master over the terminal as this is the only way he can truly get his work done and be able to work his way around certain hurdles that may come his way. Without these root commands, he would be almost disabled. Knowing these commands is as simple as knowing your way around the terminal. Without them, you might be lost.

Must-Have Commands and Their Description

There are a lot of commands available for use to a computer operator. Below is a list of the commands (some root) that are essential for the Linux user, both beginner, and expert:

  • man;

The most important command in Linux, man, shows information about other commands. With the man command, you can gain access to comprehensive details of other commands including their names, synopsis, files, errors, examples, exit status, etc. These comprehensive details make up the user manual of the commands that run in the terminal. The man command is basically used to get the necessary data relating to other commands. You can start by running ‘man man’ to find more about the man command.

  • uptime;

This command lets you know the duration of time your server has been up, as the name implies. Not only does it give you information on how long your server has been running, but it also gives you details about the number of users for the running sessions, current time information, and the average system load per time. Depending on the configurations, the uptime command can be personalized to limit displayed information.

  • w;

The “w” command looks very simplistic compared to the kind of work it does. With this command, you can actively monitor who logged into your server, and their current activities. It’s a “spy” command and is useful for users who value server privacy and would like to be informed if other people used their servers and what they were up to while using it. Like the uptime command, the w command also displays the current time and the system load average. Some fields displayed with the “w” command include USER (the name of the user logged in), FROM( the IP address of the user), TTY (named of the terminal the user used), IDLE( the last time the user accessed the terminal), JCPU, PCPU, WHAT, LOGIN@, etc.

  • users;

This command displays the user name of whoever is presently logged into your server.

  • cat;

The cat command displays, copies, and combines text files. The cat command is short for “concatenate” and would allow you to view, create, and redirect single or multiple files.

  • scp;

Input this command to copy files safely and remotely over servers. Scp is short for secure copy and is used when you want to copy files from one remote system to your own system and vice-versa. You can also use the secure copy (scp) command to send files from your own system to two remote systems.

The transmission of files or directories from one computer to another using the scp is a secure process because the files become encrypted and so, unauthorized persons cannot get hold of important information in the course of transmission.

  • locate;

As the name implies, the locate command locates files on the system by name. Sometimes, you may urgently need to find certain files on your system as speedily as possible. At such times, all you need to do is to use the locate command to bypass all the file system reading and directly locate the database to display the file requested for. To use the locate command, all you need to do is input the filename you wish to browse through.

  • chmod;

Chmod is an acronym for “change mode”. It is used to change the users who have access to a particular file. When you want to change file permissions in the Linux environment, this is the command you use. With this, you can decide what users, or user groups have access to a particular file on a server. You can also restrict the amount of access they would have with the same command. It’s necessary for security purposes.

  • chown;

To change ownership of a file, you can make use of this root command. It’s almost similar to the chmod command, the major difference being that while chmod is concerned with who has access to the files in question, chown ( which ironically sounds like ” crown”), is concerned about the ownership of the file.

  • pkill;

Using this root command, you can actively stop (or kill as the name suggests) any process running on your Linux server. This is because it is able to send signals to the processes of a running program.

  • crontab;

This is a program that is used to manage cron jobs in the Linux environment. To list existing cron jobs, simply run crontab – l. The computer system has a cron table that lists out all the programs slated to run alongside their time frames. The crontab command can be used to edit the information on the cron table.

  • alias;

Humans make use of aliases every now and then for different reasons. Aliases (or AKA) refers to a person’s unofficial or shortened name. The computer system does the same thing too. When you need to shorten a command, you can make use of the alias command. Alias in a computer system acts as shortcuts to frequently used commands and helps to manage the operator’s time and productivity.

Aliases are not automatically saved after you close the current terminal session you are working on. To save an alias, you would need to create an alias in ~/. bashrc

  • echo;

Display of output text. Used in making bash scripts. It’s basically a command that tells the computer system to repeat (display) input and is the ideal command to use when you want to write both formatted texts in the form of shell variables, filenames, directories and static text to the terminal window.

Just like echos, the computer system relays back to the user the specific input entered.

  • cmp;

For a thorough comparison of two files, input this root command. It would compare the file’s byte by byte in order to determine if they are similar or not.

  • mount;

This root command mounts a filesystem. There are other varied options in this command that can be used to even enable remote file system mounting. The main function of the mount command is to make the mounted storage device or filesystem accessible and also making such a filesystem/storage device attached to a subsisting file. To undo this process, the “unmount” command is used.

  • pmap;

Inputting this command displays the memory map of any process. The memory map shows how the memory is dispersed and shared in the computer system.

  • wget;

Write this command to download a file from a network. The wget command allows you to download multiple files from the internet, supports background downloads, and helps to manage certain bandwidths.

  • ifconfig; (This command is deprecated in modern Linux packages)

If you want to configure a network interface, this is the command that you should use. When you write this command, the necessary configuration is displayed on the screen.

Further use of the ifconfig command includes viewing all network settings, displaying information of all network interfaces, enabling network interfaces, viewing settings of specific interfaces, including disabling a network interface. The command also assigns IP addresses, netmask, broadcasts, new aliases to a network interface, and a whole lot of other configurations.

  • cd;

Also known as the “change directory” command, the cd command is used to change the directory you are currently working in. For example, to change to the download directory, just type:

cd/downloads.

  • mkdir;

With the ‘mkdir’ command, you can create directories (which are also known as folders in some operating systems). To avoid receiving a “permission denied” error message, the user must ensure that he/she has sufficient permission to create directories in the parent directory. The mkdir command has the ability to create multiple directories at a time. So while the changes current directories, the mkdir command is responsible for creating them.

  • rm;

The ‘rm’ command is an acronym for the remove command. It deletes files and directories. The way it works is to type in ‘rm’ followed by the name of the file:

rm file.txt

  • cp;

The cp command tells the operating system to “copy”. When you impute this command, you can copy files and directories from one location to another with ease.

  • mv;

In a Linux system, ” mv” command means “move”. With the mv command, you can move and rename files from one directory to another.

To move a file to another directory, you would have to run

mv file.txt /tmp’

To rename a file, you need to indicate the destination filename

mv file.txt file1.txt’

  • sudo;

The sudo command is an acronym for ” super user do”. With the sudo root command, you can run a program as another user. This would come in handy when someone else needs to use your server, and you do not want them to know your root password. All you have to do is enter the prefix sudo, and then the command

sudo command’.

With adequate permission from you (the superuser), the second user can then run programs in your operating system as though it was you running them.

  • useradd;

This command means “add user”. With this command, you can create a new user. All you have to do is input the command, plus the new username:

useradd anotheruser’

  • userdel;

The userdel command is an acronym for delete users. With this command, you can delete a user. Just input the command, plus the name of the user you want to delete:

userdel theuser’

  • groupadd;

This simply means ” add to a group”. This command enables the user to add certain data to a group. To add a group, you impute this command plus the name of the group:

groupadd thisgroup’

  • groupdel;

The “groupdel” command is the opposite of the “groupadd” command. It instructs the operating system to delete certain data from a group. To delete a group, all you need to do is input the command ‘groupdel’, and the name of the group which you intend to remove.

groupdel the group’

  • pwd;

This is one of the most common commands used in a Linux system. It means “print working directory”. You can use this command to know the exact directory you are in. It shows us the path that starts from the root.

  • touch;

With the touch command, you can create a new file. To do this, you can use the syntax below.

touch new.file”

  • du;

With the ‘du’ (disk usage) command, you can know the amount of disk used by a particular file or folder. It helps the user to learn how to manage disk space and usage. For example, to know the amount of space used by a document, simply use the following command.

du document1’

  • zip, unzip;

An operator uses the zip command to compress files into the zip archive, and in the reverse, uses the unzip command to extract files from the zip folder.

  • hostname;

The hostname command is used for identification purposes. It accesses the systems DNS(Domain Name System) and sets the systems hostname. This command would display your hostname in a host or network. Input it to know your hostname and IP address.

  • ping;

With this command, you can test your server’s connection to other servers.

When you type in ‘ping facebook.com’ for example, it should show if your server can reach Facebook servers. This utility can also be used to troubleshoot connectivity issues. This means that this is the command you use when you are experiencing issues with network connectivity and you wish to determine the cause. The ping command performs lots of functions including sending internet control message protocols (ICMP) requests to specific destinations in order to verify whether a remote destination IP is active or not.

Conclusions

Commands are instructions that must be obeyed and cannot be ignored. It’s the same thing with computer systems. Once certain computer commands( which majorly come in the form of abbreviated instructions) are inputted into the computer, the operating system has no choice but to follow through to those commands and produce the expected outputs for the operator.

Learning of commands is not only for the computer specialists or gurus, but it’s also for the average computer owner too. The importance of commands in a Linux operating system cannot be overemphasized. The use of commands helps the computer operator to have a fair idea of how the operating system works and helps him appreciate the system function better. Commands support productivity and efficiency by helping to perform certain computer operations faster. It also gives its users a sense of ownership and mastery of their computer that they would not experience if they didn’t learn to use commands.

Using a computer and having no knowledge of how to use the various commands means not using the computer system optimally. This is why it is important for every computer operator to learn these commands and practice using them consistently so that they can get used to them. With these commands, you can get work done in no time, and be the master of the terminal. Make sure to use them to your advantage and achieve the purpose intended.