Thursday, June 5, 2014

Basic Linux Commands for DBAs


General Linux Commands for DBAs
 

Command      
Description
Examples
 pwd
Displays current working directory
$ pwd
/usr/kalyan
 ls
List the current directory contents
$ ls
 ls -l
List the current directory contents with extra details
$ ls -l
 ls
Displays files for the specified path
$ ls
 cd ~ / cd
User home directory
$ cd  / $ cd ~
 cd -
Previous current directory
$ cd -
 clear
Clear screen
$ clear
 touch                                                                
Creates an empty file
$ touch abc
 rm
Removes specified file
$ rm abc
 rm -rf
-f force -r recursive, Removes complete directory with its contents
$ rm -rf
 cp file1 file2
Creates a copy of file1 to file2, if destination is file it creates a duplicate copy, if destination is directory it moves the file into that directory.
$ cp file1 file2
 cp -r dir1 dir2
Creates a duplicate copy of whole directory
$ cp -r dir1 dir2
 mv file2 file3
Renames given file to new file
$ mv file2 file3
 cat
Displays contents of the file
$ cat file1.txt
 more
Displays contents of the file page by page, for next page {Space}  to quit {q}
$ more file1.txt
 head
Displays first 10 lines from the file
$ head file1.txt
$ head -20 file1.txt (first 20 lines)
 tail
Displays last 10 lines from the file
$ tail file1.txt
$ tail -20 file1.txt (last 20 lines)
 tail -f
Displays contents of the file as it grows, starting with last 10 lines, to quit {ctrl+c}
$ tail -f Kalyan2.err
 date
Displays current date and time
$ date
 man
Display help for the given command
$ man cat
 command > filename
Redirects output to specified filename
$ date > date.txt
 command >> filename
Appends the redirected output to existing file
$ date >> date.txt
 sort file1
Sort the contents of the file
$ sort file1
 | (Pipe)
Pipes the output to other command
$ cat file1 | sort
 ps
Displays all current processes
$ ps
 top
Displays all running processes
$ top
 kill
Kills the process Id
$ kill
cal
Displays current months calendar
$ cal
 uptime
Displays current uptime
$ uptime
 w
Displays who is online (All the users who are connected to this host)
$ w
 whoami
Displays the current logged in user name
$ whoami
 finger
Displays information about the user
$ finger kalyan
 whereis
Displays possible locations of the given application
$ whereis mysql
$ whereis perl
 which
Displays which app runs
$ which mysql
$ which perl
 uname
Prints the system information
$ uname
 uname -a
Prints Kernel information
$ uname -a
 uname -o
Displays operating system
-o Operating System
-v Kernel version
-n Node Name
-m Machine
-p Processor
-a All
$ uname -o
 wc
Displays number of newlines, words and bytes in the file
$ ls -lrt | wc - l
Displays count for ls -lrt
 
 set
Displays the name and value of each shell vairable
$ set
 $HOME
To view value in any environment variable
$ HOME
 printenv
Displays all environment variable
$ printenv
 
 
 

No comments: