Home > Technical, unix commands > unix for Beginner

unix for Beginner

unix commands :

I have been working in unix for more than 2 years. So i thought of sharing my knowledge…….

Tip : Before searching about any command of unix in internet, see “man your_command”

           and remember unix is case sensitive

Simple and basic commands :

ls command :

             ls  – to list directories and files in your current working directory(pwd)

             ls “path” – to list directories and files in the given path

            e.g. ls “/var/tmp”  — this will list the directories and files in /var/tmp folder

cat command:

               cat comand – is used to view the contents of a file

               e.g. cat “fileame”

                        cat  /var/tmp/test  – will show the contents of “test” file which is in /var/tmp folder

more command:

                     more command is also used to view the content of a file but this command will give a pause in each page.

                      e.g more filename

cp command:

                  cp command is used to copy files.

                 e.g cp source destination

                   cp *.* /var/tmp/     – All the files with any extension will be  copied to /var/tmp/ folder.

                   cp -R *.* /var/tmp/ – All files and subdirectories will be copied to /var/tmp/  folder.

mv command:

                   mv command is used to move the files from one directory to another directory

                 e.g. mv source destination

                         mv *.* /var/tmp – all the files will be moved to /var/tmp/ folder.

                        mv -f source destination   -f means ,do not prompt for confirmation, just overwrite.

rm command:

                      rm command is used to delete a file in unix.

                       e.g. rm filename

                                rm *.* – delete all the files in current working directory

                                rm /var/tmp/*.* – delete all the files in /var/tmp/ folder

                                rm -f filename  -f means, do not prompt for confirmation, just delete.

mkdir command:

                 mkdir command is used to create a directory.

                  e.g. mkdir directory_name

                          mkdir test

cd command:

            cd  command is used to change directory.

            e.g  cd /var/tmp/test – changes the current directory to /var/tmp/test/

pwd command:

                     pwd command is used to see current working directory.

                     e.g pwd

                     output : /var/tmp/test/

wc command:

              wc command is used to count how many words/lines/chars/bytes

             e.g. cat file_name | wc -l – this will show how many lines in given file

                      cat file_name | wc -w – this will show how many words in given file.

date command:

                          date command is used to get the date and times .

                    e.g date – output will be “current date and time”

                        you can change date format:

                             e.g       date “+%y%m%d”

                      Get  yesterday’s date in unix

                                          date  “+%Y%m%d”  –date=”20100413 – 1 days”

                      Tomorrow’s date in unix

                                           date “+%Y%m%d”  –date=”20100413 + 1 days”

lpr command:

                       lpr command is used to print a file.

                     e.g. lpr -Pprintername filename

                    note: there should not be space between “P” and printer name

                  e.g. lpr -Pprintername -o”pgs=1″ filename

                  prints only the first page of file.

Categories: Technical, unix commands
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: