0% found this document useful (0 votes)
12 views

Day1

The document provides an overview of Unix distributions, shell basics, and essential commands for navigating and managing files in a Unix environment. It covers topics such as logging into the system, using various shells, and executing basic commands like listing files, creating directories, and managing file content. Additionally, it includes information on command options and usage for common tasks like copying files and checking system information.

Uploaded by

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

Day1

The document provides an overview of Unix distributions, shell basics, and essential commands for navigating and managing files in a Unix environment. It covers topics such as logging into the system, using various shells, and executing basic commands like listing files, creating directories, and managing file content. Additionally, it includes information on command options and usage for common tasks like copying files and checking system information.

Uploaded by

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

gdfdgdfdh

fhfjdfhjgfh
gfgjdfhgjd
hffkkfjgkfj
11-1
Distributions

Unix Distributions
 Linux
 Solaris ( Sun Micro Systems)
 HP-UX ( Hewlett Packward)
 AIX (IBM)

11-2
Basics

Shell
Shell is nothing but a Command prompt like in windows,
When you enter the commands, you get your work done

The Shell is a command interpreter, it takes each command


and passes it to the OS kernel to be acted upon. It will
displays the results of your operations on screen.

We have 'n' no.of shells available on any Unix Machine.


each one has it's own strengths and weaknesses.

11-3
Continued…

The most commonly available Shell(s) are:


1. Bourne Shell (sh)
2. Korn Shell (ksh)
3. C Shell (csh)
4. Bourne Again Shell (bash)
5. TC Shell (tcsh)

11-4
Logging into the System
 To login to your account type your user name and at the login prompt. Unix
is Case Sensitive.

 When the password prompt appears, type your password. Your password will
never displayed on screen for security Measure. It is also case sensitive

 Then You will get [username@hostname ]#


or [username@hostname <pwd>]$.

 #, means it is administrative User Login

 $, means it is Normal user Login

 And for Administrator always Username is ‘root’, and the User ID and Group
Id is 0.

11-5
Basic Commands

Commands and their options

 Each and every command will have generally some options to get
more information about the respective outputs.

 Options will be used by preceding “-”. Options will be given after


entering the command by giving some space

11-6
Working with Basic Commands

Uname: Prints system information


-a print all information
-s print the kernel name
-r print the kernel release
-v print the kernel version
-m print the machine hardware name
-p print the processor type
-o print the operating system

11-7
ls – Listing of files and directories

Options:-
-l – long listing of files

11-8
1 – file type
4 – Group membership
- Normal file
5 – File/Dir Size
d Directory
6- File/Dir creation
l Link file
/modification Date
c character file
7 – Time modified/created
b block file
8 – File name
2 – File/Dir Permissions
3 – Owner

11-9
-a – Listing of normal files/dirs and as well as hidden files/dirs

-r – Print the output in reverse order


-t – Print the output in based on time
-h – Print the file/dir sizes in human-readable format
-1 – Print the file/dir output line by line

11-10
• man – manual pages for commands or help for the commands

• Example :- man ls
• Output will be no. of pages…. To view the information line wise or
page wise follow these…

• To see the output line by line press “Enter “


• To see the output page by page press “Spacebar”
• To quit from the manual page press the “q” key

• The above three options are useful in all other Unix commands,
whenever this kind of scenario occurs.

• clear – to clear the screen.

11-11
uptime-Tells how long the system has been running

date – To know present date and time

cal – To know the present month calendar.


if you want specific month calendar in specific year
cal 3 1999 – will display the March 1999 calendar.

pwd – To get the present/current working directory.

mkdir – To create the directories


Ex:- mkdir dir1
To create multiple parent/child directories at a time
mkdir –p dir1/sdir1

11-12
Working with Basic Commands

history- prints all the previously typed commands

who – prints the name of all users who have currently logged in

who am i- prints the name and details of the current user

whoami- prints the name of the current user

w- prints full information of all the users who have currently logged in

11-13
Working with Basic Commands

free-prints the size and usage of the ram and virtual memory

du- Summarize the disk usage of each file, recursively for directories
Options:
-s –displays only the total sum for the each specified file/directory
-h –displays in human readable format

df- displays free disk space available for each mount we have
Options:
-h –displays in human readable format
-i –list of inode information
-a –includes dummy file system

11-14
Working with Basic Commands

stat –displays file system/file status


tree — lists the contents of directories in a tree like format
Options:
-a – all files including hidden files are printed.
-d – list of directories only
-f – prints the full path prefix for each file
-u – print the username along with the tree
-s – size of the file
exit – allows to exit from program, shell or come out of a linux network
logout – just to come out of a linux network

11-15
cd – To change the working directory

cd <dir_name> # Switches into specified directory.


cd .. #Moves one directory up
cd ../../ # Moves two directories up (and so on)
cd / #Move the / directory.
cd - # Go back to you were previously (before the last directory change)

11-16
• Type & check all commands: -
uname {command}

11-17
Linux File Commands

• ls # List files and directories


• ls -l # Detailed listing
• ls -a # Include hidden files

11-18
Creating Files (touch, nano)

• touch filename.txt
• nano filename.txt
Nano is a simple and user-friendly text editor used in Linux.
Type command nano filename.txt
Editor will get open
Type & press Ctrl + O to save
Type & press Ctrl + X to exit (save & Exit)

11-19
Working with Basic Commands
cat – To create/view the files.
cat > file1 - will create a file, it prompts for entering the data, after
entering the data, save the file by pressing Ctrl-D.

cat >> file1 – Will append the data to the file, it also prompts for
entering the data, save the file by pressing Ctrl-D
Behavior of cat command

You can’t edit the files using the cat command…


To view the multiple files
cat file1 file2

11-20
Some more file commands

• Opens the file in a paginated view, allowing you to scroll up and


down
less filename.txt (press q to exit)
• Similar to less, but allows you to view content page by page
more filename.txt
• Displays the first few lines of the file (default is 10)
head filename.txt
• To display a specific number of lines
head -n 5 filename.txt (Displays the first 5 lines)
• Displays the last few lines of the file (default is 10)
tail filename.txt
• To display a specific number of lines
tail -n 5 filename.txt (Displays the last 5 lines)

11-21
• If you are having an issue to understand
what is the path of directory created then
use: -
–find / -type d -name "def" 2>/dev/null

11-22
wc – To get the count of lines/words/characters
wc file1

To get the lines/words/characters output individually.


-l – no.of lines
wc –l file1

-w – no.of words
wc –w file1

-c – no.of characters
wc –c file1

11-23
Copy
cp – to copy and paste the files/directories
- Syntax to copy the files
cp [options] <source> <destination>

To copy file1 as file2 in the same location.


cp file1 file2

To copy file1 from your present working directory to some other


directory
cp file1 /opt/dir1/

while copying you want to change the file name


cp file1 /opt/dir1/file2

11-24
Copy

Contd..
To copy file1 from some other directory to your present working directory
cp /opt/dir1/file1 . ( . Means present working directory)

while copying you want to change the file name


cp /opt/dir1/file1 file2

11-25
Copy to other directory
Using cp command:-

cp try1.txt /home/ajays/def/try2.txt

Using Absolute Paths: -


cp /home/ajays/def/uvw/try1.txt /home/ajays/def/try2.txt

I got this: -
cp: cannot create regular file '/home/ajays/def/try2.txt': Permission denied

Typically occurs when you do not have the necessary permissions to perform the
copy operation on either the source file (try1.txt) or the destination directory

11-26
11-27

You might also like