Monday, 24 December 2012

Saturday, 3 November 2012

25 Basic Unix Commands you need to know | Best Unix Commands


  • Here is a simple description about the basic Unix commands a Unix learner must know.25 Unix commands are described with example.After reading all these you will get the basic idea to work on Unix.

  • rsh  -  remote shell
  • wc  - count characters, words, lines
  • telnet - log in to another machine
  • tar  - to c reate an archive, add or extract files
  • tail  - to view end of a file
  • sort  - to sort content of a directory
  • rmdir  - to remove a directory
  • rm  - to remove a file
  • pwd   find out what directory you are in
  • print  -  custom print command
  • ncftp  connecting to remote machine as anonymous
  • mv  -  for moving and renaming files
  • more - to read a file
  • mkdir - to make a directory
  • lpr  -  standard print command
  • ls -  see file list in a directory
  • head  to display first part of a file
  • grep  - to search content in a file
  • ftp- connect to a remote machine to download or upload files
  • echo - echo arguments in a command
  • date - for displaying date and time
  • cp = for copying files
  • cd and cd..- change directory
  • chmod - change permissions
  • cat- for creating and displaying short files

rsh - Basic Unix Commands


rsh

Use this command if you want to work on a computer different from the one you are currently working on. One reason to do this is that the remote machine might be faster. For example, the command
   % rsh freedom
connects you to the machine freedom

wc - Basic Unix Commands


wc

Use this command to count the number of characters, words, and lines in a file. Suppose, for example, that we have a file colors with contents
   red cloth
   green grass
   black sea
   white elephant
   blue whale
   yellow paper
Then we can do this
   % wc colors
     6      12      60 tmp
This shows that dict has 6 lines, 12 words, and 60 characters.

to view number of lines only
 % wc -l colors
     6 tmp
to view number of  words only
 % wc -l colors
     12 tmp
to view number of  characters only
 % wc -l colors
     60 tmp     

telnet - Basic Unix Commands


telnet

Use this command to log in to another machine from the machine you are currently working on. For example, to log in to the machine "freedom", do this:
   % telnet freedom

tar - Basic Unix Commands


tar

To create compressed archives of directories and files, and also to extract directories and files from an archive. Example:
   % tar -tvzf essay.tar.gz
displays the file names in the compressed archive essay.tar.gz while
   % tar -xvzf essay.tar.gz
extracts the files from essay.tar.gz.

tail - Basic Unix Commands


tail

Use this command to look at the tail of a file. For example,
   % tail poem1
displays the last 10 lines of the file poem1 To see a specific number of lines, do this:
   % tail -n 20 poem1
This displays the last 20 lines of the poem.


head - Basic Unix Commands



sort - Basic Unix Commands


sort

Use this commmand to sort a file. For example, suppose we have a file colors with contents
   red cloth
   green grass
   black sea
   white elephant
   blue whale
   yellow paper

Then we can do this:
  % sort colors
  black sea
  blue whale
  green grass
  red cloth
  yellow paper
  white elephant

To store the output in a file named sortedcolors we do this:
   % sort colors >sortedcolors

rmdir - Basic Unix Commands


rmdir

Use this command to remove a directory. For example, to remove a directory called "poems", do this:
   % rmdir poems

rm - Basic Unix Commands


rm

Use rm to remove files from your directory.
   % rm poem1
     remove poem1? y

pwd - Basic Unix Command

Use this command to find out what directory you are working in.
   % pwd
   /home/music/albums
   % ls
   album1 album2
   % cd album2
   % pwd
   /home/music/albums/album2

print - Basic Unix Command

print
This is a moderately intelligent print command.
   % print funny.txt
To print on a specific printer, do this:
   % print funny.txt printer1

ncftp - Basic Unix Command


ncftp

Use ncftp for anonymous ftp --- that means you don't have to have a password.
   % ncftp ftp.downloads.net
     Connected to ftp.downloads.net
   > get funny.txt
The file funny.txt is downloaded from the machine ftp.downloads.net.

mv - Basic Unix Commands


mv

Use this command to change the name of file and directories.
   % mv poems bestpoems
The file that was named poems is now named bestpoems

more - Basic Unix Command


more

More is a command used to read text files. For example
   % more essay
When the files are very long you need to go to the next page . Here are the basic commands
  • q --- quit more
  • spacebar --- read next page
  • return key --- read next line
  • b --- go back one page

mkdir - Basic Unix Command

mkdir
Use this command to create a directory.
   % mkdir album
To get "into" this directory, do
   % cd album
To see what files are in essays, do this:
   % ls
There is no files there yet, since you just made it. 
To create files, see cat 

lpr -Basic Unix Command


lpr

Standard Unix command for printing a file. It stands for the ancient "line printer." See
   % man lpr
for information on how it works.

head - Basic Unix Commands


head

Use this command to view the head of a file. For example,
   % head poem1
displays the first 10 lines of the file poem1 . To see a specific number of lines, do this:
   % head -n 30 poem1
This displays the first 30 lines of the poem

grep - Basic Unix Commands


grep

This command is used to search for information in a file or files.
For example, suppose that we have a file colors whose contents are
   red cloth
   green grass
   black sea
   white elephant
   blue whale
   yellow paper

Then we can search  items in our file like this;
   % grep blue colors
      blue whale
   % grep red colors
     red cloth
   
Grep can also be combined with other commands. For example, if one had a file of phone numbers named "mob", one entry per line, then the following command would give an alphabetical list of all persons whose name contains the string "Fred".
   % grep Fred ph | sort
     Alpha, Fred: 333-6565
     Beta, Freddie: 656-0099
     Frederickson, Molly: 444-0981
     Gamma, Fred-George: 111-7676
     Zeta, Frederick: 431-0987

ftp -Basic Unix Command


ftp

Use ftp to connect to a remote machine, then upload or download files
Example 

We'll connect to the machine download.net, then change director to myfiles, then download the file movie
   % ftp solitude
     Connected to download.net
     220 download.net FTP server (Version wu-2.4(11) Sat Nov 4 17:26:33 MDT 2012) ready.
   Name (solitude:carlson): mathew
     331 Password required for mathew.
   Password: 
     230 User mathew logged in.
   ftp> cd myfiles
     250 CWD command successful.
   ftp> get movie
   ftp> quit

By default download will be in ascii format.If you want to change it into binary mode do the following 
ftp> binary
ftp> put movie

echo -Basic Unix Command


echo

The echo command echoes its arguments. For example
   % echo write
     write
% echo laptop
     laptop

date -Basic Unix command

date command is used to check the date and time.
   % date
Sat Nov  4 08:52:42 MST 2012

cp - Basic Unix commands

cp to copy file or directory

   % cp song song.2
This makes a copy of the file song
   % cp ~/albums/song .
This copies the file song in the directory albums to the current directory. The symbol "." stands for the current directory. The symbol "~" stands for the home directory.

cd and cd.. -Basic Unix commands

chmod -Basic Unix commands

" chmod " to change the permissions of a file or directory
For example to make file xy readable by every user
 % chmod a+r xy
To make a file with shell script command1 executable, we do this
   % chmod +x command1

Sunday, 7 October 2012

cat -- for creating and displaying short files | Unix Commands

cat

used to create, view and concatenate files.
To create a file named  file1
   % cat >file1
     line 1 
     line 2
<control-D> 
   %

<control-D>  tells the computer that what is typed is the content of the  file file1

To view a file we use cat in a different way:
   % cat file1
    line 1 
    line 2
%
To add text to an existing file 
   %  cat >file1
     line 3 
     line 4
<control-D> %
If we want to join 2 files named file1 and file 2 and create a new file named as file3
   % cat file1 file2 >file3
We could check the number of lines in the new file like this:
   % wc -l file3

Enhanced by Zemanta

Monday, 1 October 2012

ls - Basic Unix command

Here i am describing " ls "command which is one the basic Unix command
ls    --- used to list files in your system
ls -l --- used to list your files in 'long format', which contains information like size of the file,owner of the file,modified date,permissions etc.
ls -a --- used to list 'all files', including the ones whose filenames begin in a dot,that means hidden files also.

Welcome to Linux and Unix Commands

Warm welcome to a site about Linux and Unix commands.This site is for all Linux newbies and also for intermediate users who want to become more about linux. Learning basic commands is the first step in learning about linux.Here we discuss basic as well as advanced commands for different types of linux users.
Enhanced by Zemanta