In a world that is hyped over Graphical User Interface (GUI), servers commands are not dead yet. No matter how easy the frontend might become, the backend has, and will always, comprise of server commands that need years to master. Whether you are a budding developer or a seasoned sysadmin, you cannot deny that some Linux commands are indeed inevitable.
We collaborated with our developers and asked them 15 Linux basic commands that they thought was crucial to their success. Having done so, we then compiled a list of over two dozen commands, and filtered out 15 from them.
These commands work for Linux in –
- development environment
- virtual machines
- containers, and
- bare metal
Linux basic commands to start with development
Uptime command is probably the simplest Linux server command that notifies the administrator how long the system has been up and running. Utilizing this command you can see for how long your VMs have been running and whether you are billed correctly.
Besides, ‘uptime’ will also compute load on the system and the number of users that are logged in currently.
Syntax of Uptime command –
# uptime -p
You can have the system to display output differently. The –p flag tell the system to display output in an easy-to-read format.
who displays information about remote users connected to the system. who Linux command is not going to display what the user is up to but it can show who all are connected. who, however, has more options than other commands of similar type.
Linux Server Command syntax for who
# who -b
# who -d
# who –ips
The –b (or – boot) is the flag to print when the system was last booted. –d (or –dead) shows processes that are dead.
–ips prints the IP instead of their username. This is helpful when you want to trace back to an IP address.
- 3. less
The less command is perhaps the simplest of all Linux server commands but is also equally robust.
Experienced admins will find the program to be extremely useful, given the number of features it is packed with.
Less enables users to view files and scroll through them quickly. Since less is a robust Linux command, it is recommended to learn less command separately.
We have, however, included the less command syntax for your better understanding.
# less /var/log/viewfilesless.log
You would find the tail command extremely useful when viewing log files. tail command was among the Linux server commands that our developers used the most.
The advantage of pulling out last portions of a file is that it the most prone to errors. If you notice bugs on your server, you should start by unrolling changes that you last made.
Syntax of tail command
# tail /var/log/example.log
# tail -f /var/log/example.log
The –f options allows you to follow logs as they are created. This is helpful if you want to have a record of files you have and haven’t explored.
80% of our developers agreed that no server admin can work without having a clue of curl command. 30% of them agreed that curl is the most basic Linux server command they first learnt.
curl is a really powerful utility that can help you to transfer files from web. curl often takes numerous optional arguments, allowing it to perform a plethora of complex operations with ease.
# curl websitename.com/filenamehere.txt
# curl websitename.com/filenamehere[1-100].txt
# curl –help
Curl is very versatile and inevitable if you want to be a professional server administrator. We recommend you to check ubuntupit’s guide to productive curl commands.
scp command might not be very well known but we use it a lot at Go4hosting. scp can easily transfer files between Linux hosts.
scp stands for secure copy and is most widely used while transmitting files within a network. Note that the hosts need to be on the same network.
Though primarily used for transferring files, scp packs a number of compelling features such as SSH access, secure cipers, etc.
Syntax of scp Linux server command
# scp [email protected]emote_host:filename.txt /local/documents/
This command will download the text file (filename.txt) from a host (user) to your local/documents folder.
This is the most useful Linux server command we have come across so far, and also the earliest command that you learn on your pursuit to become seasoned server administrator.
None of our developers used ping as much as the IT helpdesk. This is because ping command test the connection between local host and remote machines hosted on the same network. Note that ping is not fetching any results if you are not connected.
You can ping to any website or machine. Note the syntax of this Linux server command –
# ping google.com
# ping yoursite.com
# ping -c 3 example.com
In our organization, IT helpdesk used ping the most. They do so while troubleshooting IPv4 and IPv6 connections on our server.
Do not get confused between who and whois server commands. Though these Linux server commands sound alike, they differ a lot from each other.
The whois command lets Linux administrators to search for useful contents in WHOIS database. This Linux command is also often misused for finding sensitive information about a host.
whois Linux command syntax
# whois google.com# man whois
whois can display a huge amount of info. It is for this reasons it is most often used with tools like grep (grep filters out desired info from the unwanted).
rsync is a great replacement for the rcp utility. It allows administrators to easily synchronize files between source and its destination.
The rsync tool is faster and better than rcp. It makes for an ideal choice for Linux server administrators.
This Linux server command can transfer all the HTML files at once to remote host. Below is an example of how you can do so.
# rsync –t *.html new-server:public_html/
The tcpdump command is another Linux server command that guys from IT helpdesk use so often.
The command displays TCP and IP packets that are received and transmitted from your system. It is necessary to keep a note of such packets to safeguard against anonymous data packets that might be extorted remotely from the network.
# tcpdump -c 15
# tcpdump –help
tcpdump, by default, will continuously capture data packets in and out of the system. You can specify the command to capture a certain number of packets using –c flag and denote the number of packets you need.
That wraps up the 10 basic Linux server commands. It is now time we move to some tedious and advanced-level codes for advance server administrators.
Advanced Linux server commands for mid-level admins
- echo command
echo is one of the most powerful Linux server commands, whether you believe it or not. You can do a number of things using this command such as creating files, checking return codes and viewing system variables.
Here is how you can create a new file using echo –
$ echo This is an example file > test.txt
You can use quotes around the file name, though I prefer not to do so. Some say that the echo command with quotes looks more pleasing.
$ echo “This is a test file” > test.txt
You can also append files with echo command. To do so, you need to place the append redirect operator >>
$ echo “This is how you append text”>> test.txt
- top and kill
The top process does so much than just displaying Linux processes. First, it the very start of system troubleshooting, and second, you can easily identify processes that are causing troubles to the system and put them to an end.
Once you have successfully typed in the command, you will see a list of processes on your computer.
kill Linux server command
There are two ways to kill a command in Linux – the polite kill (also known as soft kill) and the sigkill.
$ kill -15 <PID>
$ kill -9 <PID>
Polite kill lets the process complete. SIGKILL, however, ends tasks then and there, abruptly.
passwd command is used for a number of things. Standard users use this Linux server command to update their passwords, while admins can modify passwords without knowing the current token.
Here is how the command works –
$ kill -9 <PID>
Changing password for user Go4hosting.
Current password: Demopass123
New password: Updatedpass123
Retype new password: Updatedpass123
passwd: all authentication tokens updated successfully.
If you are the administrator of a dedicated server, you can do a number of things more.
$ sudo passwd Go4hosting
New password: ChangedGo4hosting123
Retype new password: ChangedGo4hosting123
passwd: all authentication tokens updated successfully.
When changing your password, you’ll notice that the system does not respond with any dots, stars, or even blank spaces. This feature is far more secure in situations where someone is shoulder surfing during a password change. There is also no option for showing the password. Again, very secure.
If you noticed, there is no way you can view the password, although you can change it. This makes the system secure. This Linux server command is helpful in scenarios where a user can no longer recall password.
If you remember we skimmed through grep in the basic Linux server commands section because it was too early to know of them.
You can use the grep command to identify patterns inside a batch of files. For example, say that there is a file in your directory. One of the files there contains phone number of your client. You remember the client’s name but aren’t able to recall where you stored it.
The phone number was stored somewhat like –
UrgentClientNumber: +91 XXX XXX XXXX
You can use the grep tool to search inside all files and check whether any of them contains the results you searched.
Here is how it would look –
$ grep UrgentClientNumber *
grep: data: Is a directory
grep: docs: Is a directory
grep: documents: Is a directory
grep: form: Is a directory
grep: forms: Is a directory
I have asked grep to search all documents, including forms. Now you would see how this works.
Grep could not find any result in the directory so I searched in the subdirectories.
$ grep -R UrgentClientNumber *
documents/clientcontacts.txt: UrgentClientNumber pumba
Here you can see that the function returned the result.
There’s certainly a great deal to find out about this topic. I love all the points you made.
I’d incessantly want to be update on new blog posts on this web site, saved to fav!
That is very fascinating, You’re an overly skilled blogger. I’ve joined your feed and stay up for seeking more of your fantastic post. Also, I have shared your site in my social networks!!
Тhis design is steller! Youu most certainly know how to keep a readeг amused.
Between your wit and yur ѵideos, I ᴡas almost moved to start
my օwn blog (wеll, almost…HaHa!) Fantаstic job.
I rеɑlly enjoyеd ᴡhat you had to say, and more than that, how you presented it.