basic commands in linux, pwd - mkdir - rmdir - rm - cp - mv - cd - touch - ls

Опубликовано: 27 Август 2026
на канале: Janade Academy
3
1

pwd: Display the current working directory
pwd -L: Show the logical path (default)
pwd -P: Show the physical path, resolving symbolic links
ls: It displays the contents of a directory, including files, directories, symbolic links, and other filesystem objects.
ls -l : Long Listing Format
ls -lh: Human Readable Sizes
ls -a :Linux hides files beginning with a period (.).
ls -A: almost all files
ls -lt: Sort by Modification Time
ls -ltr: Reverse Order
ls -lhS: Sort by Size
ls -R: Recursive Listing
ls -d: display only the directory
ls -i: Show Inode Numbers
ls -n: Show Numeric User IDs
ls -l: Follow Symbolic Links
Combining Options: Instead of ls -l -t -r -h use ls –ltrh
This means: Long listing , Sort by time, Reverse order And Human readable sizes
Aliases: alias ll='ls -alF’
cd: is used to navigate between directories in the Linux file system
cd .. : Go Up One Directory
cd ~: Go to the Home Directory
cd -: Return to the Previous Directory
mkdir: is used to create one or more new directories in the Linux file system.
mkdir -p folder1/folder2/folder3: with -p Linux automatically creates all missing parent di
mkdir -p app/{config,logs,scripts}: Create Multiple Nested Directories
mkdir -m 755 website: Set Permissions During Creation
mkdir -pv: Show every directory being created
rmdir: is used to delete empty directories from the Linux file system.
rmdir -p f1/f2/f3: Remove Nested Empty Directories(Remove Parent Directories Automatically)
rmdir -pv: Display every directory being removed
rm: is used to permanently delete files and directories from the Linux file system.
rm -r: Remove directories with files insides
rm -i: Ask for confirmation before deleting each file
rm -v: Display every deleted file
rm -f : Force Removal, Delete files without confirmation Even if the file is write-protected
rm -d : remove emty directories(similar to rmdir)
rm --one-file-system: Do not cross filesystem boundaries during recursive removal.
rm --no-preserve-root: Allow recursive removal of the root (/). Extremely dangerous.
rm --preserve-root: Prevent accidental removal of the root directory (default on most systems).
rm --preserve-root=all: Reject recursive deletion if any argument is on a different filesystem.
rm --interactive=never: Never prompt for confirmation.
rm --interactive=once: Prompt only once before a large deletion.
rm --interactive=always: Always prompt before deleting each file.
cp: is used to copy files and directories from one location to another.
cp -r: Copy directories
cp -R: -R and -r usually behave the same on GNU/Linux.
cp -p: Preserves: Permissions, Ownership (if possible),Timestamps
cp -a: Preserves Permissions, Ownership, Symlinks,Timestamps, Recursive copy and it si Equivalent to -dR --preserve=all
cp -v: Verbose Mode
cp -i: Interactive Mode
cp -f: Overwrite existing files without prompting.
cp -n: Do Not Overwrite, Existing files remain untouched
cp -u: Copies only newer files.
cp -b: Backup Existing Files
cp -s : Creates a symbolic link instead of copying
cp -d: Preserve Symbolic Links
cp --remove-destination: Remove Destination Before Copy
cp --preserve=mode,ownership,timestamps: Preserve Specific Attributes
cp --sparse=always: Efficiently copy sparse files
mv :is used to move files and directories from one location to another or rename them.
mv -i : Ask before overwriting
mv -f :Overwrite without asking.
mv -n: Never Overwrite
mv -u :Move only if the source is newer.
mv -v: verbose mode
mv -b: Backup Existing File
mv --suffix=.bak: move only the files with extention .bak
mv --exchange: Exchange Two Files
mv -T src dest: Treat destination as a file
mv -t dir file1 file2: Specify target directory
Touch: Create Empty Files or Update Timestamps
touch -c:Create File Only If It Doesn't Exist
touch -a:Change Only Access Time without change modification Time
touch -m: Change Only Modification Time
touch -d "2025-01-15 10:30" report.txt: Specify Date
touch -t 202601151430 file.txt: Specify Timestamp
touch -r original.txt backup.txt: Copy Timestamp from Another File