03. LINUX commands(2) - Uchiha3000/LINUX_docx GitHub Wiki
Linux commands part 2
Understanding the directory line
drwxr: directory read write execute. These character represent the permission i.e. read and write permission for the directory named AkashD01.
2: If the represented number is 2 or more then it is a directory else if it is 1 then it is a file.
ec2-user ec2-user: The first "ec2-user" is the owner name. The second "ec2-user" is the group name. In Linux whenever we create a user, that user must be assigned under a group since it is compulsory for every user. In this case the user is "ec2-user" and the user is under the group named "ec2-user".
17: This number represents the size of the file in bytes.
[Note:- 8 bits: 1 byte, 1024 bytes: 1 kb, 1024 kb: 1 mb, 1024 mb: 1 gb, 1024 gb: 1 tb ]
17 Sep 18 05:19 : This represents the date and time the directory was last modified.
AkashD01: This is the directory name.
How to sort the long list based on the time of modification?
code: ls -tl (ls space -time) Now this is in ascending order.
How to sort the long list in descending order?
code: ls -rtl (ls space -reverse time) (Note: Some times in industry your mouse may not work or you don't have a scroll bar. This code comes handy then.)
How to check which is directory and file without the long list format?
code: ls -p (ls space -p) (Note: The names that end with a '/' like 'D01/' is a directory or else it is a file)
How to separate the list names with a comma?
code: ls -m
How to check which is directory and file, without the long list format. In addition they should be separated by comma?
code: ls -pm
How to check the hidden files and directory in LINUX?
code: ls -a (Note: Those file names that start with a dot are hidden files or directories)
How will you differentiate the hidden files from the hidden directories?
code: ls -aprt (ls space -aprt) (Note: a is for hidden files and directories, p is for checking which are directories, r is for reverse order and t is for time)
How to show hidden file along with long list?
code: ls -al
How to check the files inside a directory in long list format?
code: ls -l AkashD01
How to create a subdirectory in the directory AkashD01?
code: mkdir AkashD01/asd01 (Note: This code only works if the parent directory is created)
How to create a subdirectory along with the parent directory in a single line of code?
code: mkdir -p AkashD02/asd02
What does the 3 represent?
Ans: The 3 represent that u012 is a parent directory and it has 1 sub directory.
How to redirect a long list command output in a file?
code: ls -l > Af01
How to see the content of any file in LINUX?
code: cat Af01 (cat space filename) or (cat space filepath)
How to print the output of a calendar in a file?
code: cal 2025 > Af01
How to write inside a file?
code: cat > Af02 (Note: to save ctrl + d) (Note: A new file can also be created using this command)
How to append inside a file?
(Note: By writing the code in the previous way, when you write the code again the previous part will be deleted to keep both the previous text and the new text we have to append it) code: cat >> Af02
How to append a calendar in your file?
code: cal 08 2025 >> Af02
How to print the long list in reverse order in file?
code: ls -rtl >> Af02
How to read a file page by page?
code: more Af02 (more space filename)
How to check the first 10 lines from the file?
code: head -10 Af02
How to check the last 10 lines from the file?
code: tail -10 Af02