(Linux Command Line) Part 1 – Linux Commands for Server Management and Monitoring

0
4
Linux Command Line
Linux Command Line

Linux is an open-source Operating System, typically used on servers because it is high stable, secured and free. Linux is primarily based on Command Lines (Linux Commands), similar to the previous Microsoft DOS. Linux server administration is quite complicated, it requires certain knowledge and experiences.

Linux Command Line
Linux Command Line

Serial Linux Commands:

  >> Part 1 – Linux Commands for Server Management and Monitoring
  >> Part 2 – Linux Commands for File and Folder/ Directory Management
  >> Part 3 – Linux Commands for File Editor in Linux (CentOS, Ubuntu)
  >> Part 4 – Linux Commands for Network Configuration in Linux (CentOS, Ubuntu)
  >> Part 5 – Other Useful Linux Commands (CentOS, Ubuntu) you need to know

In this serial articles of Linux Commands, I will summarize and classify all the useful Linux Command Lines into groups so that you can easily understand and use. There are many ways we can connect to a Linux Server via SSH from a terminal (to perform a Command Line), you can use Putty, OpenSSH …

Linux Commands Line for Server Management and Monitoring
Linux Commands Line for Server Management and Monitoring

Linux Commands for Server Management and Monitoring

Linux server administration includes many tasks, such as: System Monitor (CPU status, memory status, processes…), service management, user management, user roles (create users, change passwords, permission …), reset server, run tasks or schedule task …

Below tables are the most important Command Line you need to know to start managing a Linux Server. Most command lines apply to both Ubuntu and CentOS

1. System information

COMMAND PURPOSE / DESCRIPTION
  cat /proc/cpuinfo Check CPU information (number of core, family, vendor, clock speed…)
  cat /proc/meminfo Check RAM usage status – used by each process/ service
  cat /proc/version Check Linux Kernel version
  cat /proc/ioports Check I/O port information
  cat /etc/redhat-release Check Centos (and other Redhat) version
  uname -a Check Kernel information
  free -m Check memory (RAM and SWAP) usage status – summary
  init 0 Shuttown the server (similar to shutdown -h now or telinit 0)
  df -h Display system files and disk usage status
  du -sh Display the capacity of the current folder/ directory
  du -ah Display the capacity of sub-folders and files in the current folder
  du -h –max-depth=1 Display the capacity of direct child sub-folders in the current folder
  df  Display the capacity of hard disks and all its partitions
  lspci Display the mainboard information
  /sbin/ifconfig Display the IP configuration of the server
  hostname Display the hostname of the server
  finger user@server Collect details about the current user
  arch Check server’s architech
  cat /proc/swaps Check SWAP information (SWAP in Linux is very similar to Virtual RAM in Windows)
  last reboot Check reboot history of the server

2. Linux Commands to shutdown, restart… Linux server

COMMAND PURPOSE / DESCRIPTION
  logout Kill the current session
  reboot Restart the server
  shutdown -r now Restart the server (similar to the command reboot)
  shutdown -h now Shutdown the server immediately
  shutdown -h 9:30 Shedule for shutting down the server (the server will shutdown at 9:30)
  shutdown -c Cancel all scheduled shutdown commands
  telinit 0 Turn off the server (similar to the command shutdown -h now)
  init 0 Turn off the server (similar to the command shutdown -h now ortelinit 0)
  exit Exit the current terminal window
  halt Turn off the server (similar the command shutdown)
  sleep Pause/Sleep the system (similar to Sleep in Windows)

3. Linux Commands for User management in Linux (CentOS, Ubuntu)

COMMAND PURPOSE / DESCRIPTION
  passwd Change password (standard user can only change his password, while  root user can change the password of any user)
  pwck Check the syntax and data format of user/password (/etc/passwd)
  useradd Create a new user, eg: useradd -c “New user 1” -g Group1
  userdel Delete a user
  usermod Change/ Edit/ Modify user information (group, user name…)
  groupadd Create a new group (group user)
  groupdel Delete a group
  groupmod Modify/ Edit group information, eg: groupmod -n “old group name”  “new group name”
  who /w Display all logged in users in the system
  uname Display system name (host)
  id Display user id (user identification number)
  logname Display current logged in user name
  su Login the system with other user (similar to Secondary Logon feature in Windows)
  groups Display all groups that the current user belongs to
  #vi /etc/passwd Display list users
  #vi /etc/group Display list groups
  chmod [file,folder]  Set permission for file/ folder (only the file/ folder owner can perform this command)
  chown user [file, folder] Set/ Change the owner for file/ folder
  chgrp group [filefolder] Set/ Change the owner-group for file/ folder

4. Linux Commands for Service and Process management in Linux (CentOS, Ubuntu)

COMMAND PURPOSE / DESCRIPTION
  top Similar to Task Manager in Windows, it will display all the information/ status of the system resource (processes, services, average load). Command top -d will allow you to set a refresh duration
  ps -u username Display processes performed by a user
  ps -U root Display all processes except system processes
  ps –A Display all running processes
  ss Display all connecting/ open sockets
  ss -l Display all open ports
  w username Check the logged in user, login history, processes running by this user
  vmstat 3 Control behaviors of the system, hardware and system information
  ps Displays all the current running program
  uptime Display the uptime and load average of the system
  rpm Check, uninstall or install a .RPM package
  yum Install a packaged program (like rpm)
  wget Download from a URL
  sh Run an .SH program
  startx Start xwindows mode from a terminal window
  yum update –y  Update Linux (CentOS)
  stop/start/restart Stop/ Start or Restart a service or a program, eg: service mysql stop or /etc/init.d/mysqld start
  kill Kill a proccess (the super-user can kill all processes, standard users can kill only processes run by the user)
  kill PID or %job  Stop/ Kill a process by the ID (Process Identification Number) or job number
  pstree Display all processes in a process-tree
  service –status-all Check all the service status
  whereis mysql Display the location that the service is installed (eg: MySQL)
  service –status-all |     grep abc Check the status of a particular process
  kill -9 PID Force close a process by process ID
  kill -1 PID Force close a process ID then re-load the default config of the process

5. Other Usefull Linux Commands for Server Management

COMMAND PURPOSE / DESCRIPTION
  clear Clear the command window (similar CLS in MS-DOS)
  hwclock Fix BIOS calendar
  cal Display system calendar
  date Display date, time of the system
  date –s “27 SEP 2011 14:26:00” Set system date-time by a string
  date +%Y%m%d -s “20130318″ Set system date by a string (time does not change)
  date +%T -s “00:29:00″ Set system time by a string (date does not change)

If you need any further help, feel free to contact us by leaving a comment

Don’t forget to follow us on social channels to get latest tips.

Cheers.

LEAVE A REPLY

Please enter your comment!
Please enter your name here