Linux OS Management Commands

Linux OS Management Commands

10:51, 01.07.2022

Article Content
arrow

  • Basic Linux commands for network management
  • Linux commands for viewing documentation
  • Basic Linux commands for network management
  • Basic Linux commands for network management
  • Linux user environment commands
  • Linux console commands for working with text
  • Basic Linux commands for network management

When it comes to Linux, most people immediately recall the famous meme from the cult movie "The Hangover", in which Zach Galifianakis appears surrounded by complex mathematical formulas. As if only the chosen ones were able to master the art of Linux management, and for ordinary mortals, this is something incomprehensible. By "the chosen ones" we mean bearded programmers who are able to sort an array with random numbers using the "bubble" method with one eye, and who are able to count linear algorithms in their minds.

All this, of course, is overblown hyperbole, but in fact, managing the Linux operating system will not cause any problems even for a beginner. All you need is to study the basic commands of the Linux terminal, understand their meaning and bookmark this article in case you need to refresh your knowledge. It will take a little practice to understand the logic of the OS, and then everything will go like clockwork. So, let's go.

Basic Linux commands for network management

Let's start with the IP command, a standard tool needed by any self–respecting network administrator. This command is used both to configure new PCs and to systematically eliminate network problems that may appear over time. The IP command allows you to:

  • get information about network addresses;
  • manage traffic routing;
  • output data about all network devices, interfaces, and tunnels.

Its syntax looks like this:

ip <OPTIONS> <OBJECT> <COMMAND>

The most significant is the keyword <OBJECT>, where you can substitute a variety of keys:

  • address — the protocol address (IPv4 or IPv6) on the device.
  • tunnel — IP tunnel.
  • route — routing table entry.
  • rule — a rule in the routing policy database.
  • vrf — control of virtual routing devices and traffic redirection.
  • xfrm — IPsec policy parameters.

For clarity, here are some examples of the correct use of the IP command in the daily life of the sysadmin.

  • [root@server ~]# ip address show – show in the terminal the IP addresses assigned to the interface on the server;
  • [root@server ~]# ip address add 192.168.1.254/24 dev enps03 – assign an IP address to the interface;
  • [root@server ~]# ip address del 192.168.1.254/24 dev enps03 – remove IP address from the interface;
  • [root@server ~]# ip link set eth0 up – change the interface status, in our case we enable eth0;
  • [root@server ~]# ip link set eth0 down – disable eth0 interface status;
  • [root@server ~]# ip link set eth0 promisc on – switch eth0 to network packet reception mode;
  • [root@server~]# ip route add default via 192.168.1.254 dev eth0 – add the default route used by all addresses through the local gateway available on the eth0 device;
  • [root@server ~]# ip route delete 192.168.1.0/24 via 192.168.1.254 – delete the route for 192.168.1.0/24 that uses gateway 192.168.1.254 for access.

There are also many other commands, we have only given the most common variants of them.

There are also a number of other important network commands:

  • MTR is a program that functions in command-line mode, is needed to diagnose networks, it is actively used to eliminate existing problems. It has the syntax "mtr <options> hostname/IP". The mtr command allows you to diagnose the route and connected devices – for example, if the server response time increases or if the number of lost packets increases.
  • Tcpdump – this utility allows you to capture and analyze data packets, it can be installed on the server using the command [root@server ~]# dnf install -y tcpdump. The utility's capabilities even allow you to filter traffic and "grab" only those packets that come from a specific host. For example, to capture packets coming from the address 7.7.7.7, you can use the following command: [root@server ~]# tcpdump -i eth0 -c 10 host 7.7.7.7.
  • Netstat – this tool is used to get information about all network connections and routing tables. By default, it may not be present in the system, then the utility will need to be installed using the command [root@server ~]# dnf install net-tools. It is often used without any parameters, unchanged: [root@server ~]# netstat.
  • Ping – this tool helps to check at the IP level the possibility of communication of individual TCP/IP systems. Allows you to diagnose network integrity problems, and is extremely simple and easy to use.
  • Nslookup – This Linux terminal command is used to perform DNS queries and obtain similar information about IP addresses and domains. For example, using the command [root@server ~]#nslookup hostzealot.com you can get the A-record of the specified domain.

Now let's move on to other categories of useful Linux commands.

Linux commands for viewing documentation

Reference information and documentation can be accessed using the following commands:

  • Whatis – display a brief description of the program;
  • Whereis – show the full path to the executable file;
  • File – allows you to identify the file type or its extension;
  • Program_name —help – get detailed information about the specified program or utility;
  • Whoami – display the user's UID.

Linux user environment commands

  • SU / SUDO – allows you to run the program on behalf of a specific user. The difference between SU and SUDO is that the first command is executed with switching to another user, and the second only executes the command on his behalf. SUDO is used more often, it is considered safer.
  • DATE – display the date and time, it can also be used to format the data display as you like, set a different time format, etc.
  • ALIAS is an interesting command that allows you to synonymize other Linux commands. That is, you can create new ones, group old ones, or simply change the names of existing ones. A cool thing for shortening long and hard-to-remember commands.
  • UNAME – displays key information about the system, it is recommended to use with the -a parameter.
  • UPTIME – shows the time of continuous operation of the system. It is used to find out when the server was last restarted.
  • SLEEP – allows you to turn off the computer or server after a certain time.

Linux console commands for working with text

  • LESS – needed to view long text that does not fit on the screen. Useful when the terminal does not support scrolling.
  • HEAD / TAIL. The first command displays the first 10 lines from the file, the second shows the "tail", that is, the last 10 lines of it. You can change the number of rows displayed using the -n option.
  • GREP – helps to find the text according to a given template.
  • SORT – sorts the text strings according to the specified criteria. For example, the -n option allows sorting by numeric values.
  • WC is a useful tool that allows you to count words, strings, bytes, and characters in an object.
  • DIFF – used to compare two files line by line. Moreover, an important advantage of this command is that only different rows are displayed, while matches are ignored.
views 5m, 32s
views 2
Share

Was this article helpful to you?

VPS popular offers

Other articles on this topic

How to modify hosts file
How to modify hosts file
cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.