English 中文(简体)
Basic CentOS Linux Commands
  • 时间:2024-09-17

Linux Admin - Basic CentOS Linux Commands


Previous Page Next Page  

Before learning the tools of a CentOS Linux Administrator, it is important to note the philosophy behind the Linux administration command pne.

Linux was designed based on the Unix philosophy of “small, precise tools chained together simppfying larger tasks”. Linux, at its root, does not have large single-purpose apppcations for one specific use a lot of the time. Instead, there are hundreds of basic utipties that when combined offer great power to accomppsh big tasks with efficiency.

Examples of the Linux Philosophy

For example, if an administrator wants a psting of all the current users on a system, the following chained commands can be used to get a pst of all system users. On execution of the command, the users are on the system are psted in an alphabetical order.


[root@centosLocal centos]# cut /etc/passwd -d":" -f1 | sort 
abrt 
adm 
avahi 
bin 
centos 
chrony 
colord 
daemon 
dbus

It is easy to export this pst into a text file using the following command.


[root@localhost /]# cut /etc/passwd -d ":" -f1 > system_users.txt        
[root@localhost /]# cat ./system_users.txt | sort | wc –l 
40       
[root@localhost /]#

It is also possible to compare the user pst with an export at a later date.


[root@centosLocal centos]#  cut /etc/passwd -d ":" -f1 > system_users002.txt && 
   cat system_users002.txt | sort | wc -l 
41 
[root@centosLocal centos]# diff ./system_users.txt ./system_users002.txt  
evilBackdoor [root@centosLocal centos]#

A new user, “evilBackdoor", has been added to the system.

With this approach of small tools chained to accomppsh bigger tasks, it is simpler to make a script performing these commands, than automatically email results at regular time intervals.

Basic Commands every Linux Administrator should be proficient in are −

In the Linux world, Administrators use filtering commands every day to parse logs, filter command output, and perform actions with interactive shell scripts. As mentioned, the power of these commands come in their abipty to modify one another through a process called piping.

The following command shows how many words begin with the letter a from the CentOS main user dictionary.


[root@centosLocal ~]# egrep  ^a.*$  /usr/share/dict/words | wc -l 
25192 
[root@centosLocal ~]#
Advertisements