In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what are the interesting Linux command line tips", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn what are the interesting Linux command line tips?
1. Lock or hide files or directories in Linux
The easiest way to lock a file or directory is to use Linux file permissions. If you are the owner of a file or directory, you can prevent other users and groups from accessing it (delete, read, write, execute), as follows:
$chmod 700 tecmint.info or $chmod go-rwx tecmint.info
To learn more about Linux file permissions, read this article to manage users and groups, file permissions and properties in Linux [5].
To hide files or directories from other users in the system, you can add them at the beginning of the file or directory. The way to rename:
$mv filename .tecmint.info
2. Convert rwx permissions to octal format in Linux
By default, when you run the ls command [6], it will display file permissions in rwx format. In order to understand the equivalence between rwx format and octal format, you can learn how to convert rwx permissions to octal format in Linux [7].
3. How to use the su command when the sudo command fails
Although the sudo command [8] is used to execute commands with superuser privileges, it also fails in some cases, as shown below.
Here, I want to empty the contents of a large file called uptime.log, but even I failed to execute it using the sudo command.
$cat / dev/null > / var/log/uptime.log$ sudo cat / dev/null > / var/log/uptime.log
Empty the contents of a large file in Linux
In this case, you need to use the su command to switch to the root user, and then perform the emptying operation as follows:
$su$ sudo cat / dev/null > / var/log/uptime.log$ cat / var/log/uptime.log
Switch to superuser
Try to understand the difference between su and sudo [10], and read their man pages for more guidelines:
$man sudo$ man su
4. End a process in Linux
Sometimes, when you want to use kill, killall, pkill commands to end a process [11], they may not work, and you may see that the process is still running on the system.
If you want to force the termination of a process, you can send a-KILL signal to the process.
First get the specified process ID [12], and then end the process as follows:
$pidof vlc$ sudo kill-KILL 10279
Find and end processes in Linux
Check the kill command [13] for more usage options and information.
5. Delete files in Linux
In general, we delete files from the Linux system by using the rm command. However, these files have not been actually deleted, they are still stored there and hidden on your hard drive, and other users can still recover the deleted files [14] and view them in Linux.
To prevent this from happening, we can use the shred command to overwrite the contents of the file and choose to delete the file after the overwrite is complete.
$shred-zvu tecmint.pdf
The options used in the above command describe:
-z-* overwrite with 0 at a time to hide the overwrite action.
-u-truncate and remove the file after overwriting.
-v-displays the detailed process.
Delete files in Linux
Read the shred manual for more usage information.
$man shred
6. Rename multiple files in Linux
You can rename multiple files in Linux at any time by using the rename command [15].
The rename command renames the specified file according to the rules in the * * parameters.
The following command renames all .pdf files to .doc files, using the rule's /\ .pdf $/\ .doc /':
$rename-v's /\ .pdf $/\ .doc /'* .pdf
Rename multiple files in Linux
In the next example, we will remove the extension by renaming all files that match "* .bak", using the rule of's /\ e.bakroomapapple:
$rename-v's /\ e.bakmarch bak'*.
7. Check the spelling of words in Linux
The look command is used to display any line in a file prefixed with a specified string, and it can also help you check the spelling of a given word on the command line. Although it is not so effective and reliable, it is still a useful substitute for other powerful spell checking tools.
$look linu$ look docum
Check the spelling of words in Linux
8. Search man pages by keyword
The man command is used to display the man pages of the command, and when the-k option is used, it uses the keywords printf (or keywords adjust, apache, php in the following command) as regular expressions to search for all man pages that match that name and display its introduction.
$man-k adjust$ man-k apache$ man-k php
Search man pages by keyword
9. Monitor the log in real time in Linux
The watch command can periodically execute another Linux command [16] and display the execution result of the command in full screen. The logging of the log file can be monitored when the watch command is used with the tail command [17] (the Linux command to see the end of the file).
In the following example, you will monitor the system authentication log file in real time. Open two terminal windows and monitor the log file in real time in * * windows, as follows:
$sudo watch tail / var/log/auth.log
You can also use the-f option of the tail command [18] (the Linux command that displays the end of the file) to monitor file changes in real time. In this way, we can see the log generation in the log file.
$sudo tail-f / var/log/auth.log
Next, run the following command in the second terminal window, after which you can observe the contents of the log file in * terminal windows:
$sudo mkdir-p / etc/test$ sudo rm-rf / etc/test
10. List all Shell built-in commands
A shell built-in command is a command or function that is called internally and executed directly in shell, rather than loading an external executable program from the hard disk.
List all shell built-in commands and their syntax, and execute the following command:
The above $help is all the contents of this article entitled "what are the interesting Linux command line tips?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.