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

Files Commands

Uploaded by

Hamza Fawad
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)
11 views

Files Commands

Uploaded by

Hamza Fawad
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/ 1

Files Commands

1. ls - List directory contents

 ls - Lists all files and directories in the current directory.


 ls -l - Lists files and directories with detailed information (permissions, owner, size, etc.).

2. cd - Change directory

 cd /home/user - Moves to the /home/user directory.


 cd .. - Moves up one directory level.

3. pwd - Print working directory

 pwd - Displays the current directory path.

4. cp - Copy files and directories

 file2.txt - Copies file1.txt to file2.txt.


 cp -r dir1/ dir2/ - Copies the directory dir1 to dir2.

5. mv - Move or rename files and directories

 mv file1.txt file2.txt - Renames file1.txt to file2.txt.


 mv file1.txt /home/user/ - Moves file1.txt to /home/user/.

6. rm - Remove files or directories

 rm file1.txt - Deletes file1.txt.


 rm -r dir1/ - Deletes the directory dir1 and its contents.

7. touch - Change file timestamps or create empty files

 touch newfile.txt - Creates an empty file named newfile.txt.


 touch file1.txt - Updates the timestamp of file1.txt if it already exists.

8. cat - Concatenate and display file content

 cat file1.txt - Displays the content of file1.txt.


 cat file1.txt file2.txt - Displays the content of file1.txt followed by file2.txt.

9. chmod - Change file modes or Access Control Lists

 chmod 644 file1.txt - Sets read and write permissions for the owner, and read-only permissions for others.
 chmod u+x script.sh - Adds execute permission for the file owner on script.sh.

10. chown - Change file owner and group

 chown user file1.txt - Changes the owner of file1.txt to user.


 chown user:group file1.txt - Changes the owner of file1.txt to user and the group to group.

You might also like