Jump to Main Content
Content > Linux > Common Commands
Common Commands

Some common commands that I can't always remember, but may also be helpful to anyone running linux.


You can type help, but it seems to be generally useless. You gotta know the commands. 

  • ls -al: like dir on DOS.
  • man command - manual pages for command
  • tail -n XX filename - the last XX lines of filename. main log is stored at /var/log
  • head filename - first XX lines of filename
  • ps -A - to see all processes by all users (-a for all by your user, without subcommand to get just your shell). use ps -aux to list all the running processes. ps pid where pid is the Process ID (found using the previous command, you get additional useless info).
  • kill XXX - to kill a process. to get a process ID (XXX), look in /var/run or run ps -A. /etc/rc.d/init.d has startup and stop scripts (for RedHat). Or kill pid. Or kill -f pid.

Problems?: See the /var/log/messages file. Use tail -n XX /var/log/messages to see the last XX lines of the logfile. I've also setup an alias command for logtail and loghead for 25 lines each.

Managing Users and Groups

  • id username - shows info on the username including groups, etc.
  • groups username - shows info on the groups belonging to. similar to id
  • useradd, userdel, usermod - manages users
  • groupadd, groupdel, groupmod - manages groups
  • passwd - update a user's authentication token(s)
  • last - shows the last X users logged into the server; can use last -f <filename> to see others previous. lastb shows the last bad login attempts (if setup).

VI/VIM Commands

  • :help - open help file (Ctrl-] to surf; Ctrl-T or -O to go back); :q to close help file and return to editor
  • :w - write
  • :q - quit; :q! quit without saving
  • :wq - write and quit
  • u - undo
  • Ctrl-R or :red - redo
  • /pattern - highlight all matching pattern (regex)
  • /pattern/x - jump to xth match
  • / - move to next match
  • ? - move to previous match
  • :[range]s/pattern/string/[g][c] - replace pattern with string; g is global; c requires confirmation; a range of 1,$ will do whole file
  • i - insert (before cursor)
  • a - append (after cursor)
  • x - delete character
  • dd - delete line
  • . - repeat command
  • N yy - yank N lines into register
  • :reg - shows registers


Part of Findutils: Website | Documentation

Finding and fixing permissions for files/directories:

find . -type f -not -perm 644 | xargs chmod 644
find . -type d -not -perm 755 | xargs chmod 755
chmod 444 mainfile.php

Other Pages
Previous Page Name Services (Bind) Running X-Windows at Startup Next Page
Comments are solely the opionion of the author and not to be construed as the opinion of anyone else.


Remember me

Lost Password?

Register now!



(c) 2006-2007 - Mark Boyden
Privacy - Legal Stuff - Contacts