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_namemkdir -p project/src/componentscreate nested foldersrmdir directory_nameremove empty directoryrm -r directory_nameRemove a directory with files insiderm -rf directory_nameForce delete (no confirmation)sudo rm -rf directory_nameIf you get permission denied (used sudo)ls directory_namelists of all content of this directoryls -lwith detailsls -awith hidden filesls -lhwith human readable sizepwdpresent working directorycd folder_namechange directorycd ..go one level backcd ~go to home directorycd /go to root directorycd -go to previous directorycp -r source_folder destination_foldercopy directorymv old_name new_namemove/rename directoryls | wc -lcount file in directoryxdg-open folder_nameopen directory in file managerwatch ls folder_namewatch live changespwd && ls -lahmodern used commands combodu -sh folder_namecheck directory sizels -ld folder_namedirectory permissionchmod 755 folder_namechange permissionsudo chown user:user folder_namechange owner
treesee folder structuresudo apt install treetree myfolderyou can used this as well
find / -type d -name folder_namefind 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:
| Part | Meaning |
|---|---|
d | Directory (- means file) |
rwx | Owner permissions |
r-x | Group permissions |
r-- | Others permissions |
Permission Type
| Symbol | Meaning | Action |
|---|---|---|
r | Read | View file |
w | Write | Edit/Delete |
x | Execute | Run file / Enter folder |
User Type
| Symbol | Meaning |
|---|---|
u | Owner (User) |
g | Group |
o | Others |
a | All |
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)
| Number | Permission |
|---|---|
| 0 | --- |
| 1 | --x |
| 2 | -w- |
| 3 | -wx |
| 4 | r-- |
| 5 | r-x |
| 6 | rw- |
| 7 | rwx |
Example:
chmod 755 myfolder
Means:
- Owner ?
7?rwx - Group ?
5?r-x - Others ?
5?r-x
Common Permission Presets
| Permission | Meaning | Command |
|---|---|---|
755 | Public folder | chmod 755 folder |
644 | Normal file | chmod 644 file.txt |
700 | Private folder | chmod 700 folder |
777 | Full 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
