System Administration Linux Command

System administration Linux commands are used to manage and monitor the operating system and its resources. 

These commands include:


reboot

"reboot" is a Linux command used to restart the system. It is executed with superuser privileges and it causes the system to go down, restart, and go back up again. 

The basic syntax of the command is:

reboot [Options]

Options available for reboot command include:

  • -f or --force: Forces the system to go down and restart immediately, bypassing the normal shutdown procedures.
  • -n or --no-sync: Skips the step of writing all unwritten data to disk before rebooting, which can make the reboot faster but may cause data loss.
  • -w or --wtmp-only: Only updates the wtmp (login accounting) file, without actually rebooting the system.
  • -h or --halt: Halts the system after shutting it down.

Before using the reboot command, it's important to make sure all running processes have been saved and all open files have been closed to prevent data loss.


shutdown

"shutdown" is a Linux command used to shut down or reboot the system.

Usage: 

shutdown [OPTION]... [TIME] [WALL...] 

Options: 

  • -r, --reboot: reboot the system 
  • -h, --halt: halt the system 
  • -P, --poweroff: power-off the system 
  • -H, --halt, --poweroff: halt or power-off the system 
  • -c, --cancel: cancel a running shutdown 
  • -k, --kill: don't halt or power off, only send warnings 
  • -q, --quiet: don't display messages Time: 
  • +m, --time=minutes: time to wait before shutting down 
  • -t, --timeout=seconds: time to wait before shutting down 

Wall message: 

[message] message to be sent to all users

Note: Only the root or a user with the proper permissions can execute this command.


init

"init" is the first process started by the kernel when the system boots and is responsible for starting other processes and setting up the system environment. The init process has a process ID (PID) of 1 and is executed by the kernel as the last step of the boot process.

"init" can take different forms, with the most common being sysvinit, upstart, and systemd. Each form provides a different set of features and management of the boot process and system processes.

"init" is used to:
  • Start system services and daemons
  • Control the runlevels of the system
  • Reap and restart orphaned processes
  • Configure the system environment, such as setting up the PATH variable
  • Manage system shutdown and reboot.


systemctl

"systemctl" is a system management command in Linux that allows controlling the state of the system and services. It is a front-end for the "systemd" system and service manager.

systemctl can be used to:
  • Start, stop, restart, reload, or status of a service
  • Enable or disable service to start at boot time
  • List all services and their status
  • Show system status, including system uptime, load average, and logged-in users
  • Control the state of the system, including rebooting, shutting down, hibernating, and suspending.

"systemctl" has a variety of options and sub-commands, a few common ones include:

  • systemctl start <service> - starts a specified service
  • systemctl stop <service> - stops a specified service
  • systemctl status <service> - displays the status of a specified service
  • systemctl list-units - lists all units and their status
  • systemctl is-active <service> - shows if a service is running or inactive
  • systemctl enable <service> - enables a specified service to start at boot time.

"systemctl" is a powerful tool that should be used with caution as improper usage can result in system instability.


chkconfig

"chkconfig" is a Linux command-line utility used to manage the system startup scripts in System V-based operating systems such as Red Hat and Fedora. It provides a way to enable or disable specific services from starting during the boot process, and also to manage the levels at which they start (for example, whether a service starts in runlevel 3, runlevel 5, or both). 

The syntax for using chkconfig is:

chkconfig [options] service_name [runlevels]

For example, to disable the httpd service from starting during the boot process, the command would be:

mrdev@kali:~$ chkconfig httpd off

To check the current runlevel settings for a service, the following command can be used:

mrdev@kali:~$ chkconfig --list httpd

The --list option displays the runlevel status for all services, and the runlevel status for a specific service can be displayed by specifying the service name.


service

The service command is a tool to control system services on Linux systems. It provides an interface to manage system services using the init system.

Syntax: 

service <service_name> <command>

Commands:

  • start: starts the specified service
  • stop: stops the specified service
  • restart: restarts the specified service
  • status: displays the status of the specified service
  • reload: reloads the configuration of the specified service without restarting it

Note: This command may not be available in all distributions as some have transitioned to using the systemctl command.


top

"top" is a real-time system monitoring tool in Linux that displays system statistics such as CPU usage, and memory usage, and processes information in a dynamic and interactive fashion. By default, it refreshes the display every few seconds, providing an ongoing display of the most resource-intensive processes on the system.

Some common options/flags include:
  • -d DELAY: Specifies the refresh rate (in seconds) for the display
  • -n NUMBER: Specifies the number of iterations (updates) the command should run for
  • -p PID: Show statistics for the specified process ID (PID) only
  • -u USER: Show statistics for the specified username only
  • -h: Displays the help screen for the top.

Example usage: 

top (Displays the system statistics)

username@TechnoScience:~$ top


ps

The ps command is a Linux utility that shows information about the currently running processes and their status. Some of its basic usage and options are:

Display information about the current terminal's processes.

username@TechnoScience:~$ ps

Display information about all processes running on the system, along with their parent process IDs, start time, and CPU usage statistics.

username@TechnoScience:~$ ps -ef

Display information about all processes running on the system, along with the process owner, CPU, memory usage statistics, and process start time.

username@TechnoScience:~$ ps -aux

Display information about all processes running on the system, along with the process ID, parent process ID, CPU usage statistics, and thread information.

username@TechnoScience:~$ ps -eLf

ps -p [pid]: Display information about the process with the specified process ID.

username@TechnoScience:~$ ps -p 1021

The "ps" command is a powerful tool for monitoring the performance and status of processes running on a Linux system. By using the appropriate options, you can filter the output to display only the information that you're interested in.


free

"free" is a Linux command that is used to display the total amount of free and used physical memory and swap space in the system.

Usage:

free [Options]

Options: 

  • -b, --bytes: Display the amount of memory in bytes. 
  • -k, --kilo: Display the amount of memory in kilobytes (default). 
  • -m, --mega: Display the amount of memory in megabytes. 
  • -g, --giga: Display the amount of memory in gigabytes. 
  • -h, --human: Display the amount of memory in a human-readable format. 
  • -c, --count=N: Repeat the display N times. 
  • -s, --seconds=N: Wait N seconds between each display. 
  • -t, --total: Show the total sum of memory. 
  • -V, --version: Show version information.

Example:

username@TechnoScience:~$ free
              total        used        free      shared  buff/cache   available
Mem:        1511588      209896      337320        3292      964372     1121920
Swap:       1535360           0     1535360
username@TechnoScience:~$

The output shows the total memory, used memory, free memory, shared memory, buffer/cache memory, and available memory in the system.


df

display information about disk usage and available space

username@TechnoScience:~$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev              722484       0    722484   0% /dev
tmpfs             151160    1024    150136   1% /run
/dev/sda1       32426780 4791320  25965216  16% /
tmpfs             755792       0    755792   0% /dev/shm
tmpfs               5120       4      5116   1% /run/lock
tmpfs             755792       0    755792   0% /sys/fs/cgroup
tmpfs             151156      12    151144   1% /run/user/1000
/dev/sr0           51806   51806         0 100% /media/username/VBox_GAs_7.0.6
username@TechnoScience:~$


du 

display information about disk space usage of files and directories

username@TechnoScience:~$ du
576 ./Downloads
4 ./.tldr
4 ./Documents
8 ./.config/pcmanfm/default
12 ./.config/pcmanfm
8 ./.config/featherpad
<SNIP>


uptime

display the system uptime and load average

username@TechnoScience:~$ uptime
 04:14:15 up 15:20,  1 user,  load average: 0.06, 0.03, 0.00
username@TechnoScience:~$


vmstat

 display information about system processes, memory, paging, block I/O, and CPU activity.

username@TechnoScience:~$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 336816 103980 860716    0    0     8    32  117  316  0  0 97  3  0
username@TechnoScience:~$

iostat

display statistics about input/output operations

username@TechnoScience:~$ iostat
Linux 4.15.0-88-generic (TechnoScience) 02/03/2023 _x86_64_ (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.15    0.32    0.25    2.58    0.00   96.70

Device             tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.00         0.01         0.00        516          0
sda               0.87         8.68        32.81     477533    1804364

username@TechnoScience:~$


lsof

 list open files and the processes that have them open

username@TechnoScience:~$ lsof


lspci

display information about PCI buses and devices on the system

username@TechnoScience:~$ lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:02.0 VGA compatible controller: VMware SVGA II Adapter
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service
00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)
00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB
00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0b.0 USB controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller
00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)
username@TechnoScience:~$

lsusb

display information about USB buses and devices on the system

username@TechnoScience:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
username@TechnoScience:~$


systemctl

manage system services and daemons

username@TechnoScience:~$ systemctl


journalctl

view system logs.

username@TechnoScience:~$ journalctl
These commands provide insight into the system's resources and performance and are essential for effective system administration.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Ok, Go it!