Вы находитесь на странице: 1из 4

Page 1

LINUX CONSOLE COMMANDS

Help Commands
Command Use/Description
command –help Lists general information about the
command, including switches
man command Lists the page from the built-in manual
about the command. This contains
very detailed information about the
command.
info Displays information and
documentation on shells, utilities and
programs.

Directory and file location commands


Command Use/Description
cp source destination Copies a file from source to destination
mv source destination Moves a file from source to destination.
Also renames file source to destination.
rm filename Deletes (removes) a file
rmdir filename Deletes (removes) a directory
mkdir filename Creates (makes) a directory
ls Lists the contents of a directory
ln existingfile new-link Creates link to an existing file (hard
link)
ln –s existingfile new-link Creates link to an existing file (soft link)

A “cheat sheet” of the most commonly used commands in Linux


Page 2

LINUX CONSOLE COMMANDS


File processing commands
Command Use/Description
grep string filename(s) Looks through filename(s) for a string
head [-n] filename Displays the first 10 lines of filename. If –n is
specified, displays the first n lines of filename
tail [-n] filename Displays the last 10 lines of filename. If –n is
specified, displays the last n lines of filename
diff filename1 filename2 Displays the differences between filename1
and filename2
file filename Displays the information about file contents
cat filename Displays the contents of a file in the terminal.
sort filename Displays and sorts the contents of a file
vi [filename] Opens the vi editor
pico filename Opens the pico editor
emacs filename Opens the emacs editor
find directory switches filename Finds the location of a filename starting from
otherswitches directory. Does more than locate, such as:
delete files, change owners, display by
permission, etc.
locate filename Finds the location of a filename

Other helpful commands


Command Use/Description
clear Clear the screen
whoami List who is logged in the session
echo string Copies string to a terminal
date List the current date and time
cal Display a calendar
whereis command Displays a command’s location in the directory
structure
who List currently logged in users
startx Goes from command mode to graphical mode

A “cheat sheet” of the most commonly used commands in Linux


Page 3

LINUX CONSOLE COMMANDS

File compression commands


Command Use/Description
tar switches filename Depending upon the switches value, combines
filesToCompress (but NOT compresses) a list of
filesToCompress into a filename, or extracts
the files in the filename
gzip switches filename Compresses (and decompresses) the file
compress filename Same as gzip
zcat filename Displays the contents of a compressed file

Standard input and output information


Command Use/Description
command1 | command2 Send the standard output from command1 to
command2
command > filename Send the standard output from command to the
filename
command < filename Use the data from the filename as the input for
command
command >> filename Append the output from command to the file

Special characters
Command Use/Description
* Wildcard (one or more characters)
? Wildcard (one character)

Printing commands (lpd)


Command Use/Description
lpr filename Sends filename to the printer
lpq queuename Lists files in the printing queue
lprm filename Removes file from the printing queue

A “cheat sheet” of the most commonly used commands in Linux


Page 4

LINUX CONSOLE COMMANDS

File and system administration commands


Command Use/Description
quota Displays disk usage and limits
passwd Changes the password
dmesg Displays kernel ring buffer
W Lists currently logged in users with processing
usage
mesg y/n Allows users to send messages to you
write user Send a message to another user
talk user Allow two way chat to other users
chmod permissions filename Change file access permissions
chown user filename Changes the owner of a file
su username Log in as another user without closing the
session
vmstat List virtual memory usage
free List information like the amount of RAM and
virtual memory usage
nice param jobnameOrOwner Changes the priority of a job
top Views processor usage
bg %jobnumber Moves job to the background
fg %jobnumber Moves job to the foreground
kill PID Stops a job from running
ps Lists the jobs that are running and have run
df Lists all mounted file systems
jobs Lists all the current jobs
fdisk Partition management utility
mkswap Format a swap partition
mount mountSystem Mount a disk to the mountSystem
useradd Add a new user
groupadd Add a new group
usermod Change information about a user
groupmod Change information about a group
userdel Deletes a user
groupdel Deletes a group
fsck Similar to Windows command chkdisk, it
checks the disk for errors and fixes any surface
errors

A “cheat sheet” of the most commonly used commands in Linux