Extra content for the linux , some commands related to the linux / terminal so that it will be easy for the developer to work with the terminal

Some useful commands for the terminal

1 .Directory related

  • mkdir directory_name
  • mkdir -p project/src/components create nested folders
  • rmdir directory_name   remove empty directory
  • rm -r directory_name  Remove a directory with files inside
  • rm -rf directory_name  Force delete (no confirmation)
  • sudo rm -rf directory_name  If you get permission denied (used sudo)
  • ls directory_name  lists of all content of this directory
  • ls -l with details
  • ls -a with hidden files
  • ls -lh with human readable size
  • pwd present working directory
  • cd folder_name change directory
  • cd .. go one level back
  • cd ~ go to home directory
  • cd / go to root directory
  • cd - go to previous directory
  • cp -r source_folder destination_folder  copy directory
  • mv old_name new_name move/rename directory
  • ls | wc -l count file in directory
  • xdg-open folder_name open directory in file manager
  • watch ls folder_name watch live changes
  • pwd && ls -lah modern used commands combo
  • du -sh folder_name check directory size
  • ls -ld folder_name directory permission
    • chmod 755 folder_name change permission
    • sudo chown user:user folder_name change owner
  • tree see folder structure 
    • sudo apt install tree
    • tree myfolder you can used this as well
  • find / -type d -name folder_name find directory
    • example
    • find /home -type d -name myproject


       

Linux Permission Commands

Linux permission commands are super important for security and daily work

 

Check File & Directory Permissions

ls  -l

Example output:

drwxr-xr-- 2 user user 4096 notes

Breakdown:

PartMeaning
dDirectory (- means file)
rwxOwner permissions
r-xGroup permissions
r--Others permissions

Permission Type

SymbolMeaningAction
rReadView file
wWriteEdit/Delete
xExecuteRun file / Enter folder

User Type

SymbolMeaning
uOwner (User)
gGroup
oOthers
aAll

 

CHMOD — Change Permissions

Give execute permission to owner:

chmod u+x script.sh

 

Remove write permission from others:

chmod o-w file.txt

 

Give read permission to group:

chmod g+r report.pdf

 

Give all permissions to everyone:

chmod a+rwx folder_name

 

Numeric (Octal) Method (Most Used)

NumberPermission
0---
1--x
2-w-
3-wx
4r--
5r-x
6rw-
7rwx

Example:

chmod 755 myfolder

Means:

  • Owner ? 7 ? rwx
  • Group ? 5 ? r-x
  • Others ? 5 ? r-x

 

Common Permission Presets

PermissionMeaningCommand
755Public folderchmod 755 folder
644Normal filechmod 644 file.txt
700Private folderchmod 700 folder
777Full access (?? dangerous)chmod 777 file

CHOWN — Change Owner

Change owner only

sudo chown user file.txt

Change  owner + grpup

sudo chown user:group file.txt

Change owner for a directory recursively:

sudo chown -R user:user myfolder

 

 

 

 

 

 

 

 

 

 


About author

author image

Amrit panta

Fullstack developer, content creator



Scroll to Top