Many thanks for visiting my Blog..!!Please share this blog using below share buttons and leave your Comments/Feedback/Appreciations on Tab: Feedback
Share This Blog..!!

General Unix Commands -Very Useful

Command
Action
Example
alias
Creates a temporary name for a Unix command.
alias   name command

To remove an alias:
unalias   name
ansiprint
Prints a file to a printer connected to your computer.
ansiprint   file
assets
Displays your account resources, use, and threshold.
     
bg
Places a suspended job in the background.
     
cat
Displays a specified file.
cat   file
cd
Changes current directory to a different directory.
cd   directory

To change back to your home directory:
cd    

Directory abbreviations:
~     Home directory
..     Parent directory
.       Current working directory

chmod
Changes permission status for a file or directory.
chmod   code file
chmod   code directory

To keep a file private:
chmod   600 file

To give everyone read permission:
chmod   664 file
compress
Reduces the size of a file and adds .Z to the file's name.
compress   file

To restore a compressed file:
uncompress   file.Z
cp
Makes a copy of a file.
cp   file1 file2

To copy a file into a different directory:
cp   file directory

To inquire before overwriting an existing file:
cp -i   file1 file2
diff
Compares two files and displays the differences.
     
fg
Restarts a suspended job in the foreground.
     
finger
Displays user information at the specified computer.
finger   userid@computer

To change your finger entry information:
chfn
ftp
Starts the file transfer program with a remote computer.
ftp   address
grep
Finds lines in a file matching a character pattern.
grep -icvn   pattern file

-i     Ignores case
-c     Lists count of lines that contain pattern
-v     Lists all lines except those with pattern
-n     Lists line number for each found pattern

head
Displays the first ten lines of a file.
head   file

To display the first n number of lines:
head -n   file
help
Displays an online help note.
help   note

To display a list of help notes:
help -l
history
Displays a list of your most recent commands.
history

To repeat the nth command from the list:
!   n

To repeat your most recent command:
!!
jobs
Displays active jobs and their corresponding job numbers.
jobs

To start a job in the background:
job   &

To return a job to the foreground by the job number:
fg   %number

To send a running job to the background:
z bg
kill
Terminates a process by its process identification number.
kill   pid

To use the strongest form of the kill command:
kill -9   pid
logout
Ends your computer session.

ls
Lists the files and subdirectories in your current directory.
ls -Fltra

-l     Lists long format
-t     Lists by modification time
-r     Lists in reverse order
-F     Lists file type with special character
-a     Lists all files including dot (.) files

lynx
Starts a text-only Web browser session
lynx

Starts a Web browser session at a specific Web address.
lynx   url
man
Displays Unix Manual entry for a command.
man   command

To search Manual Index for a keyword or topic:
man -k   keyword
mesg
Displays your talk and write message access status.
mesg

To set your message status to yes or no:
mesg y (or n)
mkdir
Creates a new directory within your current directory.
mkdir   directory
more
Displays a file one screen at a time.
more   file

Use to scroll forward and q to quit.

mv
Moves a file to a different directory.
mv   file directory

Moves a directory to a second directory.
mv   directory1 directory2

To rename file1 as file2:
mv   file1 file2

To rename directory1 as directory2:
mv   directory1 directory2

To inquire before overwriting an existing file:
mv -i   file1 file2
passwd
Starts program to change account password.

pico
Starts the Pico text editor with a file.
pico   file
pine
Starts the Pine® electronic mail program.

ps
Displays processes and their corresponding process identification numbers.

pwd
Displays absolute pathname of current directory.

rm
Permanently deletes a file.
rm   file

To verify prior to removal:
rm -i   file
rmdir
Deletes an empty directory.
rmdir   directory

To verify prior to removal:
rmdir -i   directory
spell
Checks the spelling in a file.
spell   file
telnet
Starts a telnet session with a remote computer.
telnet   address
vi
Starts the vi text editor with a file.
vi   file
w
Displays a list of who is on system.

wc
Counts lines, words, and characters in a file.
wc   file

Special commands and characters:

Redirection :
   
<    
Routes input to command from file
   
>    
Routes output from command to file
   
>>  
Appends output to existing file
   
|    
Routes output between commands

Wildcards used in filenames :
   
*    
Matches any number of characters
   
?    
Matches one character

Control codes :
   
s    
Suspends the screen display
   
q    
Restarts suspended display
   
d    
Signals end of file
   
c    
Cancels a command
   
z    
Suspends a process or job:
use
fg to restart
   
u    
Clears the command line


FILE COMMANDS:
 
Touch Create a new file.
Usage: touch FileName
 
cp Copy files.
Usage: cp [options] FileName1 File Name2
cp [options]
Options: -r recursively copy directory structures.
 

mv Move or Rename files or directories.
Usage: mv [options] file1 ./tmp/file1
mv [options]
Options: -i query user for confirmation.
 
rm Remove files.
Usage: rm [options] filename
Options: -r recursively remove directory structures.
-i query user for confirmation.
 
cat View complete file content.
cat
 
more View file contents in sections determined by the size of the terminal.
Usage: more
 
less View file contents in sections determined by the size of the terminal.
Has more options and search features than more.
Usage: less [options]
 
compress Reduces the size of the file. and adds the extension .Z
Usage: compress .
 
uncompress /zcatRestores a compressed file.
Usage: uncompress
Usage: zcat

 
DIRECTORY COMMANDS
cd Change directory.
Usage: cd
Eg: cd my-directory
cd go to home directory
cd .. go up one directory
 
pwd Print working directory on the terminal.
 
ls List the content of a directory.
Usage: ls [options] or ls [options]
Options: -l list all files in long format.
(permissions, users, filesize,date, and time are displayed).
-a list all files including those beginning with a “.”
-F list files distinguishing
directories/ executables* symbolic links@
-R recursively list subdirectories encountered.
 
mkdir Create a new directory.
Usage: mkdir
 
rmdir Remove a directory if its empty.
Usage: rmdir
 
SYMBOLIC LINKS
ln Create symbolic links between files or between directories.
Usage: ln [options]
ln [options]
Options: -s allows linking across file systems and allows the display
of the link’s name upon ls -l.
Eg: ln -s course-file myfile
Eg: ln -s course-directory myspace

 
TERMINAL COMMANDS
clear Clears the terminal.
 
echo: Write a string to standard output.
Usage: echo “string” or
echo ‘string’
 
repeat Repeats commands.
Usage: repeat
 
HELP COMMANDS
man Displays the manual page for the selected command.
Usage: man
rtfm Displays the man page and help files ont he terminal.
Usage: rtfm
 
INFORMATION COMMANDS
history Lists the commands typed during the session.
Options: -r displays the list in reverse.
 
hostname Displays the computer’s or server’s name on the terminal.
who Displays who is on the system.
who am i Displays the invoking user.

No comments:

Post a Comment

disqus