Monday, 12 January 2015

Mostly Used Unix Commands.

Unix Useful Commands:

This post lists commands, including a syntax and brief description.
Note: commands are  case sensitive means cp or Cp r CP all are different.
For more detail about any command you can  use man command which describe about that command.
$ man command_name
i.e. $ man cp

After type the above command you can see description about cp command.

Command used for Files and Directories:

These commands are used to create directories and handle files.

Command                    Description

cat file_name:              display file contents
cat vishwa.sh :              display contents of vishwa.sh file
 
cd dir_name  :               change directory to dir_name
cd d :                               change to d directory

chgrp  :                         change file group

chmod rwx                       Changing Permissions of file
chmod 777 test.txt           change full permission to text.txt

cp source_file  dest_file   Copy source file into destination
cp test.txt test_data.txt     copy a new file as test_data.txt

file                                    Determine file type
file test.txt                        ascii text type

find                                  Find files
find test.txt                      it print text.txt file if exist otherwise no such file or directory

grep                                 Search files for regular expressions.
grep "txt"                        it will search all file with txt type.(It is used with other commands with                                                 pipleline(|) command to concat. results.
i.e. ls | grep "txt"  It will show all the files of .txt extension on terminal.

head                               Display first few lines of a file
head test.txt                   It will display few top line of file test.txt file.

ls                                   Display information about file type.
ls                                   It will display all the files and directory at the current location.
ls -l                               It will display all files with access permission,owner,date,time etc information

mkdir                           Create a new directory name
mkdir vishwa               will create a file name as vishwa in D directory

more                            Display data in paginated form.
more test.txt               will display data in step by step format

mv                               Move (Rename a file) a oldname to newname.
mv test.txt test_copy.txt   will create a new file with name text_copy.txt

pwd                              Print current working directory.
pwd                             will print the current working directory
pwd                             /home/vishwarup (in my system).

rm                                Remove (Delete) a filename
rm test.txt                    will remove test.txt file
rm -r vishwa                will remove vishwa folder (here -r is used to remove folder).

rmdir                            Remove  an existing directory provided it is empty.
rmdir vishwa               will remove vishwa folder

tail                                Prints last few lines in a file.
trail test.txt                  will print last few line of file.(it is opposite command of head)

touch                           Update access and modification time of a file.
touch test.txt               will update access and modification time of test.txt

Manipulating data:

The contents of files can be compared and altered with the below commands.

awk                                Pattern scanning and processing language

cmp                               Compare the contents of two files
cmm test.txt test data.txt  will compare these two files

comm                  Compare sorted data

cut                     Cut out selected fields of each line of a file

diff                    Differential file comparator

expand                        Expand tabs to spaces

join                    Join files on some common field

perl                                   Data manipulation language

sed                                    Stream text editor

sort                          Sort file data
sort test.txt                       will sort all data of file test.txt

split                           Split file into smaller files

tr                             Translate characters

wc                   Count words, lines, and characters
wc test.txt    will count words,lines and characters

vi   Opens vi text editor
vi test.txt           will open vi editor with name test.txt

vim    Opens vim text editor
vim test.txt            open test.txt file in vim editor

fmt    Simple text formatter

spell            Check text for spelling error


Compressed Files:

Files may be compressed to save space.Compressed files can be created and examined by below commands:

compress                  Compress files

gunzip          Uncompress gzipped files

gzip                 GNU alternative compression method

unzip          List, test and extract compressed files in a ZIP archive

Zcat                 Cat a compressed file

Network Communication:

These following commands are used to send and receive files from a local UNIX hosts to the remote host around the world.

ftp         File transfer program

rcp         Remote file copy

rlogin         Remote login to a UNIX host

rsh        Remote shell

tftp               Trivial file transfer program

telnet       Make terminal connection to another host

ssh       Secure shell terminal or command connection

scp        Secure shell remote file copy

sftp                secure shell file transfer program

Some of these commands may be restricted at your computer for security reasons.

Misc Commands:

Chown        Change owner

date                will display date with day and time

cal        will display calender

echo               to print text on terminal
echo vishwa       will print vishwa on terminal

exit                will close the current working terminal

ps        will display the process Id

kill                to kill any process name with process id

kill process_id                to kill process_id

last                Show last logins of users

logout        log off UNIX

netstat        Show network status

passwd        Change user password

....................................













   

      

No comments:

Post a Comment