Header Ads

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

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.

Serial Linux Commands:

Bonus: E-book "Total Linux Command Line", Download Here
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 Command Line) Part 1 - Linux Commands 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

  cat /proc/cpuinfoCheck CPU information (number of core, family, vendor, clock speed...)
  cat /proc/meminfoCheck RAM usage status - used by each process/ service
  cat /proc/versionCheck Linux Kernel version
  cat /proc/ioportsCheck I/O port information
  cat /etc/redhat-releaseCheck Centos (and other Redhat) version
  uname -aCheck Kernel information
  free -mCheck memory (RAM and SWAP) usage status - summary
  init 0Shuttown the server (similar to shutdown -h now or telinit 0)
  df -hDisplay system files and disk usage status
  du -shDisplay the capacity of the current folder/ directory
  du -ahDisplay the capacity of sub-folders and files in the current folder
  du -h –max-depth=1Display the capacity of direct child sub-folders in the current folder
  df Display the capacity of hard disks and all its partitions
  lspciDisplay the mainboard information
  /sbin/ifconfigDisplay the IP configuration of the server
  hostnameDisplay the hostname of the server
  finger user@serverCollect details about the current user
  archCheck server's architech
  cat /proc/swapsCheck SWAP information (SWAP in Linux is very similar to Virtual RAM in Windows)
  last rebootCheck reboot history of the server

2. Linux Commands to shutdown, restart... Linux server

  logoutKill the current session
  rebootRestart the server
  shutdown -r nowRestart the server (similar to the command reboot)
  shutdown -h nowShutdown the server immediately
  shutdown -h 9:30Shedule for shutting down the server (the server will shutdown at 9:30)
  shutdown -cCancel all scheduled shutdown commands
  telinit 0Turn off the server (similar to the command shutdown -h now)
  init 0Turn off the server (similar to the command shutdown -h now ortelinit 0)
  exitExit the current terminal window
  haltTurn off the server (similar the command shutdown)
  sleepPause/Sleep the system (similar to Sleep in Windows)

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

  passwdChange password (standard user can only change his password, while  root user can change the password of any user)
  pwckCheck the syntax and data format of user/password (/etc/passwd)
  useraddCreate a new user, eg: useradd -c "New user 1" -g Group1
  userdelDelete a user
  usermodChange/ Edit/ Modify user information (group, user name...)
  groupaddCreate a new group (group user)
  groupdelDelete a group
  groupmodModify/ Edit group information, eg: groupmod -n "old group name"  "new group name"
  who /wDisplay all logged in users in the system
  unameDisplay system name (host)
  idDisplay user id (user identification number)
  lognameDisplay current logged in user name
  suLogin the system with other user (similar to Secondary Logon feature in Windows)
  groupsDisplay all groups that the current user belongs to
  #vi /etc/passwdDisplay list users
  #vi /etc/groupDisplay 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)

  topSimilar 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 usernameDisplay processes performed by a user
  ps -U rootDisplay all processes except system processes
  ps –ADisplay all running processes
  ssDisplay all connecting/ open sockets
  ss -lDisplay all open ports
  w usernameCheck the logged in user, login history, processes running by this user
  vmstat 3Control behaviors of the system, hardware and system information
  psDisplays all the current running program
  uptimeDisplay the uptime and load average of the system
  rpmCheck, uninstall or install a .RPM package
  yumInstall a packaged program (like rpm)
  wgetDownload from a URL
  shRun an .SH program
  startxStart xwindows mode from a terminal window
  yum update –y Update Linux (CentOS)
  stop/start/restartStop/ Start or Restart a service or a program, eg: service mysql stop or /etc/init.d/mysqld start
  killKill 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
  pstreeDisplay all processes in a process-tree
  service –status-allCheck all the service status
  whereis mysqlDisplay the location that the service is installed (eg: MySQL)
  service –status-all |     grep abcCheck the status of a particular process
  kill -9 PIDForce close a process by process ID
  kill -1 PIDForce close a process ID then re-load the default config of the process

5. Other Usefull Linux Commands for Server Management

  clearClear the command window (similar CLS in MS-DOS)
  hwclockFix BIOS calendar
  calDisplay system calendar
  dateDisplay 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.

No comments:

EasyTipz. Powered by Blogger.