Linux Directory
Created on: 2025-01-27
Tags: #Linux #Directory
Course: HPC
Linux Commands
- Check the user - whoami
- Know about the OS - uname
- Detailed info of the OS - uname -a
- Know details about CPU - lscpu
- Memory space information (not human readable)- free
- Memory space information (human readable) - free -h
- Current working directory - pwd
- Content of the working directory - ls
- Content of directory with details along with hidden files - ls -la
- Change directory - cd - No parameters for cd command, then it goes to home. - cd - will take to the last current directory - cd .. will move to the parent directory
- Make Directory - mkdir DirectoryName
- Delete an empty directory - rmdir
- Rename a directory - mv OldName NewName
- Move a directory - mv source destination
- Create an empty file - touch fileName
- Create a new file and add data
- Use CLI or GUI based editor
- CLI - vim fileName
- GUI - gedit fileName
- Delete a file - rm fileName
- Delete a directory and its contains - rm -r DirectoryName (r represents recursive).
- Prints the content of files - cat fileName
- Copy contents of a file to another file and overwrite - cat src > dst
- Copy contents of a file to another file and append - cat src » dst
- Copy a file from source to destination - cp src dst
- Copy a directory - cp -r src dst
Note: Hidden files in Linux start with a dot.
File Permissions and Ownership Commands
- File permissions are defined for three categories of users
- Owner (user): The person who owns the file.
- Group: A group of users who share access to the file.
- Others: Everyone else.
- Permissions are divided into three types:
- Read (r)
- Write (w)
- Execute (x)
- File permission structure: The permission structure is usually displayed in a 10-character format.
- Example: - rwx r-x r–
- The first character shows the type - for a regular file and d for a directory.
- The next three characters represent the permissions associated with owner.
- The next three characters represent the permissions associated with the group.
- The last three characters represent the permissions associated with others.
- To change the permission of a file - chmod u/g/a +/- r/w/x
- u/g/o/a –> User/Group/Others/All
- +/- –> Adds/Removes permission
- r/w/x –> Read/Write/Execute
- Numeric (Octal) Notation for setting permission
- Read/Write/Execute –> 4/2/1
- Example chmod 755 file.txt. Here the 775 corresponds to rwx r-x r-x
- Change owner of a file - chown owner: group file
Linked from
- No other published notes link here yet.