Unix Commands - Getting started

A command in UNIX is a program that tells UNIX system to perform certain task. A typical UNIX command can be divided into following components:
1. The command
2. command options
3. command arguments

General syntax: $<command> [options] {arguments1,arguments2..}

Lets take example of listing command "ls" to understand the UNIX command structure.


In the above example we have used ls command in three ways:
1. ls command without options and arguments
2. ls command with option -l which means log listing.
3. ls command with option -l and argument testfile.txt which is the file name for which we want to see the details.

This will provide you with the brief idea of how UNIX commands can be used. We can further use many options together.

Now, let us explore few basic UNIX commands which we will be using quite frequently while working on a UNIX environment.

Some Basic UNIX Commands

Command Description Sample Output
date Displays Current Date & Time Fri Feb 6 22:13:16 PST 2015
who Info about all logged in user khushi pts/307      2015-02-05 13:35 (152.69.36.25)
rani  pts/313      2015-02-03 10:49 (152.69.36.25)
raju pts/311      2015-02-06 15:24 (10.159.106.213)
ravi pts/324      2015-02-06 01:45 (144.20.169.171)
who am i Info about the present user root pts/52       2015-02-06 22:13 (10.191.202.3)
echo Prints at the terminal $ echo "Shell Script"
Shell Script
ls list files and directories For more information visit the following link:
http://solarisfacts.blogspot.in/p/solaris-file-system.html
cat <file name> Displays the content of the file. cat test.txt
This is a test file.
wc Counts the number of Lines, characters, words from a file $ wc -l test.txt
6 test.txt
$ wc -c test.txt
122 test.txt
$ wc -w test.txt
29 test.txt
cp <Source File> <Destination File> Copies a files from specified source to destination
mv  <Source File> <Destination File> Moves a files from specified source to destination
rm removes file or directory rm
rm -r # to remove a directory
rm -f# force remove
pwd Displays current working directory $ pwd
/home/raviranjan
cd Change directory cd /var
mkdir To create a directory mkdir test

No comments:

Post a Comment