In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what are the Unix/Linux command skills". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what Unix/Linux command skills".
> / path/to/file.log# or use the following format: > / path/to/file.log# and then delete it. How does rm / path/to/file.log record the terminal output?
Try using the script command line tool to create an output record for your terminal output.
Script my.terminal.sessio
Enter the command:
Lsdatesudo service foo stop
To exit (end the script session), type exit or logout or press control-D.
Exit
To browse and enter:
More my.terminal.sessionless my.terminal.sessioncat my.terminal.session restores the deleted / tmp folder
I made some mistakes in the articles Linux and Unix shell. I accidentally deleted the / tmp folder. To restore it, I need to do this:
Mkdir / tmpchmod 1777 / tmpchown root:root / tmpls-ld / tmp Lock a folder
I want to lock the / downloads folder under my file server for the sake of my data privacy. So I ran:
Chmod 0000 / downloads
Root users can still access it, while the ls and cd commands do not work. To restore it with:
Chmod 0755 / downloads protects files with passwords in vim
Are you afraid of root users or others spying on your personal files? To try password protection in vim, enter:
Vim + X filename
Alternatively, use the: X command to encrypt your file before exiting vim, and vim will prompt you for a password.
Clear the garbled code on the screen
Just enter:
Reset readable format
Pass the-h or-H (and other options) option to the GNU or BSD tool to get commands such as ls, df, du, and so on, output in an easy-to-read format:
Ls-lh# in an easy-to-read format (e.g. 1K 234m 2G) df-hdf-k # output in bytes, KB, MB or GB: free-bfree-kfree-mfree-g # output in an easy-to-read format (such as 1K 234m 2G) du-h # displays file system permissions stat-c% A / boot# in an easy-to-read format sort-h-a file# displays cpu information lscpulscpu-elscpu-e=cpu on Linux Node# displays the size of each file in readable form tree-htree-h / boot displays known user information in the Linux system
Just enter:
# # linux version # # lslogins # # BSD version # # logins
Sample output:
UID USER PWD-LOCK PWD-DENY LAST-LOGIN GECOS 0 root 0 0 22:37:59 root 1 bin 01 bin 2 daemon 01 daemon 3 adm 01 adm 4 lp 01 lp 5 sync 01 sync 6 shutdown 01 2014-Dec17 shutdown 7 halt 01 halt 8 mail 01 mail 10 uucp 01 uucp 11 operator 01 operator 12 games 01 games 13 gopher 01 gopher 14 ftp 01 FTP User 27 mysql 01 MySQL Server 38 ntp 01 48 apache 01 Apache 68 haldaemon 01 HAL daemon 69 vcsa 01 virtual console memory owner 72 tcpdump 0 1 74 sshd 0 1 Privilege-separated SSH 81 dbus 0 1 System message bus 89 postfix 0 1 99 nobody 0 1 Nobody173 abrt 0 1497 vnstat 0 1 vnStat user498 nginx 0 1 nginx user499 saslauth 0 1 "Saslauthd user" how do I delete files that were unzipped accidentally in the current folder?
I accidentally extracted a tarball under / var/www/html/ instead of / home/projects/www/current. It messes up the files under / var/www/html, and you don't even know which ones are misunderstood. The easiest way to fix this problem is:
Cd / var/www/html//bin/rm-f "$(tar ztf / path/to/file.tar.gz)" is confused about the output of the top command?
Seriously, you should try using htop instead of top:
Sudo htop wants to run the same command again
Just input!!. For example:
/ myhome/dir/script/name arg1 arg2 # to run the same command again! # # run the last command sudo! as the root user!
!! Runs the most recently used command. To run the recently run command that starts with "foo":
! foo# runs the last command sudo! service that starts with "service" as the root user
! $to run the command with the last argument:
# Editing nginx.confsudo vi / etc/nginx/nginx.conf # testing nginx.conf/sbin/nginx-t-c / etc/nginx/nginx.conf # after testing "/ sbin/nginx-t-c / etc/nginx/nginx.conf" you can edit this file again with vi sudo vi! $remind you on the terminal that you have to go
If you need a reminder to leave your terminal, enter the following command:
Leave + hhmm
Here:
Hhmm-time is in the form of hhmm, hh for hours (12-hour or 24-hour) and mm for minutes. All the time is converted to a 12-hour system, and it is assumed to happen in the next 12 hours.
Home sweet home
Want to enter the place you just entered? Run:
Cd-
Need to get back to your home directory quickly? Enter:
Cd
The variable CDPATH defines the search path to the directory:
Export CDPATH=/var/www:/nas10
Now, instead of typing cd * / var/www/html/, I can enter / var/www/html directly by typing the following command:
Cd html edits the file while less browsing
To edit a file that you are browsing with less, press v. You can edit it with the editor specified by the variable $EDITOR:
Less *. Cless foo.html## press v to edit files # after you exit the editor, you can continue to browse # # with less to list all the files and directories on your system
To see all the directories in your system, run:
Find /-type d | less # list all directories of $HOME find $HOME-type d-ls | less
To see all the files, run:
Find /-type f | less # list all the files in $HOME find $HOME-type f-ls | less constructs a directory tree with one command
You can use mkdir plus the-p option to create one directory tree at a time:
Mkdir-p / jail/ {dev,bin,sbin,etc,usr,lib,lib64} ls-l / jail/ copies files to multiple directories
You do not have to run:
Cp / path/to/file / usr/dir1cp / path/to/file / var/dir2cp / path/to/file / nas/dir3
Run the following command to copy files to multiple directories:
Echo / usr/dir1 / var/dir2 / nas/dir3 | xargs-n 1 cp-v / path/to/file
Leave it as an exercise for the reader to create a shell function.
Quickly find out the difference between the two directories
The diff command compares files by line. But it can also compare two directories:
Ls-l / tmp/rls-l / tmp/s# uses diff to compare two folders diff / tmp/r/ / tmp/s/
Picture: find out the differences between directories
Text formatting
You can reformat each paragraph with the fmt command. In this case, I want to split the extra-long line and fill the short line:
Fmt file.txt
You can also split long lines, but not refill them, that is, split long lines, but not fill short lines:
Fmt-s file.txt can see the output and write it to a file
Use the tee command to see the output on the screen and write to the log file my.log as follows:
Mycoolapp arg1 arg2 input.file | tee my.log
Tee ensures that you can see the output of mycoolapp on the screen and write to the file my.log at the same time.
Thank you for your reading, the above is the content of "what are the Unix/Linux command skills". After the study of this article, I believe you have a deeper understanding of what Unix/Linux command skills are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.