Last week, I published Part 1 of this five-part series titled: Linux Commands Frequently Used by Linux Sysadmins, That first article just scratched the surface of the 50 to 100 commands in my opinion that are frequently used by Linux Sysadmins and power users. Also, see Part 3, Part 4 and Part 5.
Let’s jump into another set of frequently used commands and command-line tools for analysis, troubleshooting, and Linux system administration. Listed below are some commands that I have used over the past week. In this and future series, I will group related commands together as much as possible, and also add a table of contents to interconnect all five parts.
1. Command-line Linux system monitoring.
Often it is useful to see the performance of Linux systems. That is a shortlist for quickly accessing system performance details via command line.
uptime
– Shows system uptime and load average.top
– Shows an overall system view.vmstat
– Shows system memory, process, interrupt, paging, block I/O, and CPU information.htop
– Interactive process viewer and manager.dstat
– View processes, memory, paging, I/O, CPU etc in real-time. All-in-one for vmstat, iostat, netstat, and ifstat.iftop
– Network traffic viewer. the former:iftop -i eth0
nethogs
– Network traffic analyzer.iotop
– Interactive I/O Viewer. Get an overview of storage r/w activity.iostat
– For storing I/O statistics.netstat
– For network statistics.ss
– Utility for checking sockets.
Here are some related articles I’ve written in the past covering Command-Line System Monitoring Tools:
2. ssh
– Secure command-line access to remote Linux systems.
Apart from my homelab, most of my Sysadmin related work is done remotely. With customers’ server locations in the Americas, Europe, Asia and Australia. command-line access on the remote server; You can do Use ssh
Permission,
ssh
The command provides a secure encrypted connection between a local and a remote host. ssh
Terminal access, used for file transfer (sftp), And tunnel other applications.
ssh -i [key_file] [user]@[hostname/ip] -p [port]
-i
identity_file Selects the file from which the identity (private key) is read for public key authentication.-p
Port is used to select which port to connect to on the remote host.
for example:
ssh -i path/to/key_file root@ip_address -p 2222
SSH can also be run securely on a graphical desktop using a terminal emulator like terminator,
Also, take a look telnet
And scp
– Copy files securely using scp with eg.
in part 3We will take a look at using rsync
,
3. sudo
–Execute commands with administrative privileges.
sudo
,supper Youto be DoingThe ) command in Linux is regularly used as a prefix to commands that only superuser (root) is allowed to run. If you are not logged in with root user, you can use sudo
Command to preface a command to run that command with root privileges. for example:
$ sudo apt install terminator
once you run sudo
command, as a security precaution, you will be prompted to enter the password of the current non-root user session. (not root password)
see all Documentation of Red Hat privileges,
4. cd
– Directory navigation.
cd
The command allows you to change directories. To navigate to the root directory, use:
cd /
Navigate to your home directory use:
cd
either
cd ~
Navigate one directory level up:
cd ..
Navigate to the previous directory (or back):
cd -
To navigate to a multilevel directory, use:
cd /path/to/directory/
pwd
The command shows your current directory location. pwd means print working directory. Also see ls
Order from part 1.
Example:
hydn@ubuntu:~$ pwd /home/hydn
5. cp
– Copying files and folders
cp
The command will create a copy of a file for you. for example:
cp file1 file1_backup
this order. will make a copy of “file1” Nominated “file1_backup”And “file1” will remain unchanged.
To copy a directory and its contents use the command -r
Recursive:
cp -r directory1 directory1_copy
Recursively means copying a directory and all its files and subdirectories and all their files and subdirectories etc.
6. mv
– Transferring files and folders.
The mv command is used to move or rename a file from its location to another. for example:
mv file1 file0
it will rename “file1” To “file0”,
another example:
mv file1 /home/user/Desktop/
will move “file1” in your desktop directory, but it won’t rename it.
To move and rename, you can specify a new file. for example:
mv file1 /home/user/Desktop/file0
you can substitute ~
In place of /home/user/ which is faster for commands related to home directory. for example:
mv file1 ~/Desktop/
while using sudo
command or log in as root, then ~
Root’s home directory.
7. Deleting files and folders.
Use rm
Commands to delete/delete a file in a directory. for example:
rm file1
Use rmdir
Command to delete an empty directory.
rmdir /path/to/empty/dir/
Use rm -r
To recursively delete a directory and all its contents:
rm -r /path/to/dir/
You can also create an empty file with touch
order or cat
,
touch filename
or create a new directory you can use mkdir
Permission:
mkdir newdir/
In Part 5, we will look at creating and editing files with vi
And nano
,
8. man
– To read the system reference manual.
The man command displays a manual for any terminal commands we need help or information on. All man pages include, but are not limited to, the following standard sections: name, summary, description, examples and see also.
man [command]
Example:
man ssh
9. apropos
– Find man page names and descriptions.
apropos
The command searches man page names and descriptions. It can be used to find out which commands to use for a certain task.
apropos
For example, find available commands related to firewall:
apropos firewall
10. Search your package manager for available packages.
If you want to search for packages that are not already installed on your system, you can use the following command to find packages using your Linux distro’s package manager:
Ubuntu/Debian:
apt search
either
apt-cache search
for example:
hydn@ubuntu:~$ apt-cache search "nginx web" nginx-core - nginx web/proxy server (standard version) fcgiwrap - simple server to run CGI applications over FastCGI libnginx-mod-http-dav-ext - WebDAV missing commands support for Nginx libnginx-mod-http-ndk - Nginx Development Kit module nginx-extras - nginx web/proxy server (extended version) nginx-full - nginx web/proxy server (standard version) nginx-light - nginx web/proxy server (basic version)
CentOS/Fedora/RHEL:
dnf search
OpenSuse:
zypper se
that’s it for now. If you found Part 2 useful, please share. to subscribeBookmark, and leave a comment or suggestion below.
Leave a Comment