Pages

Sunday, September 2, 2012

Basic Linux Commands


Here are a list of basic linux commands


cat filename
write contents of filename to the screen
cd directory_name
change current directory to directory_name
chmod mode file
change permissions on file to mode.
grep phrase filename
search filename for phrase and print matching lines
grep phrase
read from the standard input, and print lines matching phrase
mkdir name
Create a directory with name
man command
Find information about the command in man (help) pages
Info command
Find Information about the command
Who
Displays users who are currently logged in
grep -v phrase
print all lines not matching phrase
Whoami
User running the current terminal
History
Displays already executed commands
History –n
Cleans the history ( removed the already executed commands)
Tty
Shows the terminal type
Su
Switch user ex: su – tom , logs into the tom user account
lpr -Pprinter_name filename
Print the file filename to the printer printer_name
lpq
check the printer queue
lprm job_number
remove the print job numbered job_number from the print queue (to find out what job nuimber your print job is, use lpq.)
tocuh file
Create a file with current time stamp
Cp file location
Copies a specified file to a specified location
Mv file1 file2
Renames a file ,directory or also moves the files to a specified location
Alias
Create a alias to a command ,ex: alias tom=ls , now tom works much like ls command
Cut
Cut contents in file ,ex:cut –d: -f6 file : cuts the sixth field
Less file
Shows files in one screen full
More file
Much like less command
Head
Shows the head contents of the file
Head –n 5
Shows the head 5 line
ls
List files in current directory (not including files that start with a dot.
Tail file
Show the end part of the file
Tail –n 10 file
Shows the last 10 lines in a file
Wc
Provides information about the character count ,line count e.t.c
Locate file
Locate files (much like find command)
Fdisk –l
Shows the disk information
Chsh
Change shell
Users
Print the current user names
Id
Print the current user to whom we logged in
Last
Displays most recent logged in information
Laslog
Displays most recent login information
Free
Displays memory information
Echo “string”
Echos the string sent
Echo –e “string” > file
Writes the string to the file
Cmp
Compare files ex : cmp –l fil11 file2
Diff
Checks 2 files for differences ex:diff –by file1 file2
Cat /proc/version
Basic information about cpu
Uname
Print system information
Echo $PATH
Shows the current Path
Echo $SHELL
Shows the current running shell
Runlevel
Shows the current running run level
Ps
Shows the currently running process
Kill -9 pid
Kills the running process with ID pid
Sysctl
Interface for examining or dynamically changing parameters in linux
ls directory_name
List files in directory_name
ls -l
List files with permissions, ownership and last modified date
ls -a
list all files, including files that start with a dot (like the .netscape directory)
ls -R
list contents recursively, that is , list contents of subdirectories.
pwd
"print working directory", ie says what directory you are in
rm filename
removes filename
rm -f
f is for "force". With this option, files are removed without confirmation.
rm -r directory_name
recursively delete directory_name and its contents.
rmdir directory_name
removes a directory called directory_name. Only works on empty directories. to remove a nonempty directory, see rm -rf
telnet hostname
connect to the machine called hostname
wc filename
print the number of lines, words, and characters in filename. If No filename is given, stdin is used.
Watch
Execute a program periodically
Cron,crontab
Commands for scheduling jobs
Scp
Command for transferring file to remote destination
Unlink
Delete a file ex: unlink filename
Halt,
Halt the system
Poweroff
Halt the system and poweroff
Shutdown
Shutdown
Reboot
Reboot the system
Command
Run a command ex: command ls (runs the ls command)
Dircolrs
See the colors assigned to directories
Dir
Briefly list the directory contents
Dirs
Show remembered directory listing
Logname
Print the login name
Nl
Number of lines in a file ex:nl filename
Type
Describe a command
Ss
Dump socket stastics
Du
Disk usage
Df
File system usage
Iostat
Cpu Statistics Information
Modprobe
Load a module into kernel
Dmidecode –type 6
Ram type
Last reboot
Last reboot information
Shred
Delete files perminantlystrace
Strace
See command executing
Time
Display time
Whereis
To find location of some thing ex:whereis ls (find location of ls command)
Whatis
To get information