0% found this document useful (0 votes)
4 views6 pages

OS Lab 2

The document provides a brief overview of essential Linux commands including ls, pwd, cd, mkdir, rmdir, rm, cp, mv, touch, and file. Each command is accompanied by its explanation and syntax, detailing its functionality and options. This serves as a quick reference guide for navigating and managing files and directories in a Linux environment.

Uploaded by

mr.robot2622
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)
4 views6 pages

OS Lab 2

The document provides a brief overview of essential Linux commands including ls, pwd, cd, mkdir, rmdir, rm, cp, mv, touch, and file. Each command is accompanied by its explanation and syntax, detailing its functionality and options. This serves as a quick reference guide for navigating and managing files and directories in a Linux environment.

Uploaded by

mr.robot2622
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/ 6

Name – Parikshit Bhattacharya

Roll No – 2300291530130
Sec – V
Branch – CSE(AI&ML)

1. ls Command
Explanation:
ls is used to list files and folders in a directory. It shows what’s inside a
folder.

Syntax:
ls [options] [directory_or_path]

2.pwd Command
Explanation:
pwd (print working directory) tells you the full path of your current
location in the file system.

Syntax:
pwd [options]

• pwd -L Displays the logical path.


• pwd -P Displays the physical path.

3.cd Command
Explanation:
cd (change directory) allows you to navigate between folders.
Syntax:
cd [directory_path]

• cd alone takes you to your home directory.


• cd .. moves one level up.
• cd - switches to your previous directory.
4 . mkdir Command
Explanation:
mkdir (make directory) is used to create new folders.

Syntax:
mkdir [options] directory_name

• -p: Creates parent directories if they don’t already exist.


• -m: Set specific permissions while creating the directory.

5. rmdir Command
Explanation:
rmdir (remove directory) deletes empty directories only

Syntax:
rmdir [options] directory_name
How to Delete a Non-Empty Directory? -> rm -r mydir
6. rm Command
Explanation:
rm (remove) deletes files or directories. Be cautious as it permanently
removes them.

Syntax:
rm [options] file_or_directory

• -r Removes directories and their contents recursively (needed for


folders)
• -f Forces deletion (no warnings, even for read- only files)
• -rf Combines both: Deletes everything without asking

7.cp Command
Explanation:
cp (copy) is used to copy files and directories from one location to
another
Syntax:
cp [options] source target

• -r: Copies directories recursively.


• -i: Prompts you before overwriting a file

8.mv Command
Explanation:
mv (move) moves files and directories, and it can also be used to
rename them

Syntax:
mv source target

9. touch Command
Explanation:
touch creates an empty file or updates the timestamp of an existing
file

Syntax:
touch file_name

10. file Command


Explanation:
file examines a file and tells you what type it is (text, binary, etc.).
Syntax:
file filename

You might also like