-
1.
ls -l(Long Format)
Displays detailed information about files, including permissions, owner, size, and last modified date.$ ls -l
Example output:
-rw-r--r-- 1 user user 4096 Oct 11 10:15 file.txt -
2.
ls -a(All Files)
Lists all files, including hidden files (files starting with.).$ ls -a
Example output:
.bashrc .hiddenfile Documents/ -
3.
ls -h(Human-Readable Format)
Displays file sizes in human-readable format (e.g., KB, MB).$ ls -lh
Example output:
-rw-r--r-- 1 user user 4.0K Oct 11 10:15 file.txt -
4.
ls -r(Reverse Order)
Lists files and directories in reverse order.$ ls -r
Example output:
Videos/ Pictures/ Downloads/ Documents/ -
5.
ls -t(Sort by Modification Time)
Sorts files by their modification time, with the most recently modified files appearing first.$ ls -lt
Example output:
-rw-r--r-- 1 user user 4096 Oct 11 10:15 recent.txt -
6.
ls -S(Sort by Size)
Sorts files by size, with the largest files displayed first.$ ls -lS
To copy a folder in Linux, you can use the cp command with the -r (recursive) option. Here's how it works:
-
Basic Syntax:
cp -r <source_folder> <destination>
-
Key Option:
-ror--recursive: This tellscpto copy all files and subdirectories inside the folder recursively.
-
Copy a folder to another location:
cp -r /home/user/Documents/project /home/user/Backup/
This will copy the
projectfolder and all its contents to theBackupdirectory. -
Copy a folder and rename it:
cp -r /home/user/Documents/project /home/user/Backup/project_copy
This will copy the
projectfolder and rename the copied version toproject_copyin theBackupdirectory. -
Copy a folder to the current directory:
cp -r /home/user/Documents/project .This will copy the
projectfolder from/Documentsto the current working directory.