Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

1. Basic File Management Commands in Linux

The document provides an overview of basic file management commands in Linux, including pwd, cd, ls, touch, cat, mv, cp, mkdir, and rm. Each command is explained with its syntax and purpose, such as navigating directories, listing files, creating files, and managing file names. The document serves as a guide for users to understand and utilize these essential commands effectively.

Uploaded by

mohammed nisath
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

1. Basic File Management Commands in Linux

The document provides an overview of basic file management commands in Linux, including pwd, cd, ls, touch, cat, mv, cp, mkdir, and rm. Each command is explained with its syntax and purpose, such as navigating directories, listing files, creating files, and managing file names. The document serves as a guide for users to understand and utilize these essential commands effectively.

Uploaded by

mohammed nisath
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

HNDIT 3052 – Operating Systems (SLIATE LMS)

Basic File Management Commands


in Linux
File Management Commands
pwd Command
Pwd returns the full path name of the current remote working directory. In the
above example, the command output is /home/amisha_26, which implies that we
are working in the amisha_26 directory, which is inside the home directory.
Syntax:
$ pwd -L: Prints the symbolic path.
$ pwd -P: Prints the actual path.

Example:

cd Command
The command cd also sometimes called as chdir , it allows you to move between
directories. The cd command accepts an argument, generally the name of the
folder to which you wish to move. Thus the entire command is cd your-directory.
Syntax :
$ cd <directory_name> (Will move to the desired directory)
$ Cd .. (will move back to the previous directory)

Example:

Page 1 of 6
HNDIT 3052 – Operating Systems (SLIATE LMS)

ls Command
The “ls” command lists files that present the directory you want to work with,
except for hidden files.
In the above example, ls list all the files present in the directory named as amees.
Syntax :
$ ls

Example:

touch Command
The primary use of the touch command is to alter a timestamp. The function is
commonly used for file creation, even though this is not its core role. The terminal

Page 2 of 6
HNDIT 3052 – Operating Systems (SLIATE LMS)
program may modify and access times for any specified file. The touch command
only creates a file if it does not already exist.
Syntax:
$ touch <options> <file or directory name>
OPTIONS MEANING

-a Changes the access time

-c if the file does not exist, do not create it

-d update the access and modification times

-m change the modification time only

-r use the access and modification times of the file

-t creates a file using a specified time


Example:

cat Command
Cat or concatenate is often used in Linux. It reads the files' content and gives the
content's output on the terminal screen. In the above example, we used the
command cat to read the file1.txt and you can see the In the above example, we
used the command cat to read the file1.txt and see the output below the
command.
Syntax:
Page 3 of 6
HNDIT 3052 – Operating Systems (SLIATE LMS)
$ cat <filename>

Example:

mv Command
The mv command is often used in Linux; this command is used to move a file from
one directory to another directory. There is also a second use of the mv
command. We can change the name of any existing file to a new name, whichever
we desire.
In the above example, we are changing the name of a.txt to b.txt.
Here we are using the mv command, which will change the name of the file a.txt
to b.txt.
Syntax:
$ mv <filename> <new file name>

Example:

cp Command
Cp means to copy. The command is used to copy files or groups of files. In the
above example, we are using the cp command to copy the content of file3.txt and
will paste it into the file named file1.txt.
Syntax:
cp <file/directory-sources> <destination>

Example:

Page 4 of 6
HNDIT 3052 – Operating Systems (SLIATE LMS)

mkdir Command
“mkdir” also known as “ make directory”. This command is used to create single
or multiple directories.
Syntax:
mkdir <options> <directories>
OPTION MEANING

-v print a message for each created directory

-p no error if existing
Example:

rm Command
“rm” also know as “remove”.This command is used to remove a file. If we use the
rm command, the file will be permanently deleted. In GUIs, we got recycle bin and
trash for recovering files. So we need to take extra care while using the rm
command.
Example:

Page 5 of 6
HNDIT 3052 – Operating Systems (SLIATE LMS)

Page 6 of 6

You might also like