In the previous article, we had learned about the following:
Linux Commands |
1. apt-get update Command
2. apt-get upgrade Command
3. ls -r Command
4. Use of ". "
5. ls -a Command
6. clear Command
7. history Command
8. echo and printf Command
9. We have seen that Linux is case-sensitive
Now, let's continue further...
In the previous articles, we have seen that we can create files or directories by using mkdir Command.
Now, What, if we want to create more than one file??
Then type the command
#mkdir -VP file1/file2/file3: It will create all the files that we have to write.
- " p ": p option will create a parent directory for "file3" as needed.
#cd .. Command: It will move you to the parent directory.
#cd - Command: This command will move you to the previous directory. As hyphen is a symbol of subtraction that means it will subtract the current directory and throw you to the previous directory.
#Dir Command: It is used to list the content of a directory.
Now, there is a question?? If you want to know the structure of your files and directories, then what will you do??
Then, firstly type the command:
cd dir
and then
ls -lrt
Output: It will show you the structure.
In the previous article, we have learned about echo Command. Now, if we want to write the message on the file rather than on the screen then,
Type: echo "Hello, Everyone I hope you are enjoying the course" > hello.txt
Syntax: command name message symbol filename
Now, if we want to append more content or message, then use ">>" this symbol.
Example: echo "Hello" >> hello.txt
echo "Happy" >> hello.txt
# Cat Command: It is used to see the content of a file or directory.
Input: Cat hello.txt
Output: Hello, Everyone I hope you are enjoying the course
Hello
happy
# head -2 hello.txt Command: It is used to print the first two lines of a file or directory.
NOTE: By default the head command print the first ten lines.
Syntax: command name(head) -number of lines filename
#tail -2 hello.txt Command: It is used to print the last two lines of a file or directory.
NOTE: by default, it is also printed the last ten lines of a file or directory.
The syntax is the same as above.
#stat Command: It is used to check the stat of a file or directory.
Input: stat filename
Output: It will show the following:
1st line contains: filename
2nd line contains a Regular file with a size of 18.
3rd line contains: It shows Inode number and number of links to that Inode.
4th line contains: It told you about owner(UID), group(Gid) who has read-write permission but others have read permission.
And 3 lines show access, modified, and change time.
#du Command: It will show you the disk usage of the current directory.
Input: du
Output: 32 [In your case it would be different]
Now, if we want to copy a file in two or more than two files or directories then,
Type: cp -v hello.txt file1/file2
Output: It will copy hello.txt in file1 and file2 as well.
Here, if we want to copy all the files of the same extension from one directory to another then,
Type: cp -VR filename/* filename(In which you wanna copy)
Output: It will copy all the files of the same extension from one directory to another.
NOTE: For simple files, the cat command should be enough to verify its file integrity. But for a larger file or binary file, we can't use cat.
Then, we gonna use...
Command: md5sum
Output: You will get a hexadecimal value
- This helps in detecting accidental or deliberate file corruption.
- When transferring a file from one machine to another or downloading files from the internet, to verify the file integrity compare md5sum on the source and destination machines.
Quick Recap:
1. We have seen how we can create more than one file or directory.
2. We saw a little more of the echo command.
3. Cat Command: It is used to see the content or integrity.
4. head Command: It shows us the first ten lines of a file or directory by default.
5. tail Command: It shows us the last ten lines of a file or directory by default.
6. stat Command: It is used to see the statistics of a file.
7. du Command: It is used to check the disk storage of a directory.
8. We have learned about md5sum Command.
Previous Articles:
#Penetration Testing Tutorial for Absolute Beginners
#Technical Tools Explanation
#Linux for Absolute Beginners in Hindi
1 Comments
Very informative article and good for beginners + simple language.
ReplyDeleteIf you have any doubts, let me know