0% found this document useful (0 votes)
52 views14 pages

Linux Commands: Er. Lalit Matoliya Team Co-Ordinator, CDAC-ACTS

The document provides summaries of common Linux commands including cal, date, bc, passwd, who, pwd, cd, mkdir, rmdir, ls, and cat. Cal is used to display calendars and can show a specific month and year. Date displays the system date and time and can use format specifiers. Bc is a calculator for integer and floating point operations. Passwd is used to change user passwords. Who lists currently logged in users. Pwd shows the current working directory. Cd changes directories. Mmkdir and rmdir create and remove directories. Ls lists directory contents and has options like columns and hidden files. Cat displays and concatenates file contents, and can be used to create empty files.

Uploaded by

ch_rashmi93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views14 pages

Linux Commands: Er. Lalit Matoliya Team Co-Ordinator, CDAC-ACTS

The document provides summaries of common Linux commands including cal, date, bc, passwd, who, pwd, cd, mkdir, rmdir, ls, and cat. Cal is used to display calendars and can show a specific month and year. Date displays the system date and time and can use format specifiers. Bc is a calculator for integer and floating point operations. Passwd is used to change user passwords. Who lists currently logged in users. Pwd shows the current working directory. Cd changes directories. Mmkdir and rmdir create and remove directories. Ls lists directory contents and has options like columns and hidden files. Cat displays and concatenates file contents, and can be used to create empty files.

Uploaded by

ch_rashmi93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

LINUX COMMANDS

Er. Lalit Matoliya


Team Co-Ordinator, CDAC-ACTS

cal: The Calendar


Syntax:

cal [ [month] year ]


Example:

$ cal
cal can be used without arguments, in which case it displays the
calendar of the current month.
To see calendar for month of march 2006, you need two
arguments

$ cal 03 2006

Date : Displaying the system date


You can display the current date with the date command, which
shows the date and time to the nearest second.
$ date
Wed Aug 31 16:22:40 IST 2005
The command can also be used with suitable format specifiers as
arguments. Each format is preceded by the + symbol, followed by
the % operator, and a single character describing the format.
$ date +%m
08
$ date +%h
Aug
$ date +%h %m
Aug 08

bc : The calculator
bc is used for arithmetic operation. It is applicable for integer and also for
floating point.
$ bc
12 + 5
17
[ctrl + d]- To quit bc.
To enable floating point computation, you have to set scale to the number of
digits of precision before you key in the expression:
scale=2
17/7
2.42
bc is quite useful in converting numbers from one base to another.
ibase=2
11001010
202
The reverse is also possible
obase=2
14
1110

passwd: Changing your password


$ passwd
passwd: Changing password for kumar
Enter login password: *******
New password: ********
Re-enter new password: ********
passwd (SYSTEM) : passwd successfully changed for kumar
password expects you to respond three times. First, it prompts for
the old password. Next, it checks whether you have entered a
valid password, and if you have, it then prompts for the new
password.
Finally, passwd asks you to reenter the new password. If
everything goes smoothly, the new password is registered by the
system.

who : Who are the users?


$ who
root console

Aug

07:51 (:0)

kumar

pts/10 Aug

07:56 (mercury.heavens.com)

sharma

pts/6

02:10 (pc125.heavens.com)

Aug

UNIX maintains an account of all users who are logged on to the


system. The who commands displays an informative listing of these
users:
The first column name shows the usernames, second column shows
the device name, third, fourth and fifth column shows date and time of
logging in. The last column name shows the machine name from where
the user logged in.

pwd : Checking your current


directory
You can move around from one directory to another, but at any
point of time, you are located in only one directory. This directory
is known as your current directory.
At any time, you should be able to know what your current
directory is. The pwd (print working directory) command tells you
that:
Example:
$ pwd
/home/kumar
$pwd
/home/kumar/lalit

cd : changing the current directory


You can move around in the file system by using the cd (change
directory) command.
Example:
$ pwd
/home/kumar
$cd progs
$pwd
/home/kumar/progs

mkdir : Making Directories


Directories are created with the mkdir(make directory) command.
$ mkdir lalit
$ mkdir kunal khushi kapil

(You can create three directories)

Sometimes, the system refuses to create a directory:


$ mkdir test
mkdir : Failed to make directory test; Permission denied
This can happen due to these reasons:

The directory test may already exist.

There may be an ordinary file by that name in the current directory

The permissions set for the current directory dont permit the
creation of files and directories by the user.

rmdir : Removing Directories


The rmdir (Remove Directory) command removes directories. You
simply have to do this to remove the directory lalit:
Example:
$ rmdir lalit

[Directory must be empty]

ls : Listing Directories contents


It is used to list all the file names and directory names in the current
directory.
$ ls
lalit kunal

kapil

kanchan

khushi kamal

ls options:
Output in Multiple Columns (-x)
$ ls -x
Identifying Directories and Executables (-F)
$ ls -Fx
Showing Hidden Files Also (-a)
$ ls -axF
Listing Directory Contents
$ ls x helpdir progs
Recursive Listing $ ls -xR

cat : Displaying and Creating Files


cat is one of the most well-known commands of the UNIX system.
It is mainly used to display the contents of a file on the terminal.
$ cat dept
01|accounts|6213
02|progs|5423
03|marketing|6521
04|personnel|2365
05|production|9876
06|sales|1006

cat, like several other UNIX commands, also accepts more than
one filename as arguments:
$ cat chap01 chap02

cat : To create a File


cat is also useful for creating a file. Enter the command cat,
followed by the > (the right chevron) character and the filename.
$ cat > lalit
The contents of the second file are shown immediately after
the first file without any header information.
press [ctrl+d]
$_

[Prompts Returns]

THANK
S

You might also like