In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what commands are commonly used in Linux". In daily operation, I believe many people have doubts about what commands are commonly used in Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what commonly used commands are there in Linux?" Next, please follow the editor to study!
1. Create a folder
Mkdir ruozedata creates 1 folder
Mkdir 1 5 7 side by side
Mddir-p cascade in 2-3-5
two。 Create a file
Vi jepson.log is empty and not empty
Touch www.log create empty
Echo "" > ruoze.log has 1 byte
Cat / dev/null > data.log 0 bytes need to be emptied or newly created
3.mv
Mv www.log www.log20180519 Mobile + renamed
4.cp
Cp jepson.log 7 Fil
Cp-r 7 5 folder with-r parameter
Think: who is faster, mv or cp?
Mv (because cp moves twice as much as mv)
5. Delete
Rm file (romove abbreviation)
Rm-f forcibly delete files
Rm-rf forcefully deletes a folder (f=forc means mandatory)
Thinking: rm-rf / use with caution
6. Environment variable
Alias rzd='cd / root/ruozedata' (temporarily understood as alias)
Global:
[root@ruozehadoop001 ~] # vi / etc/profile
# alias
Alias rzd='cd / root/ruozedata'
[root@ruozehadoop001 ~] # source / etc/profile
Source means to execute, available. Instead of, that is. / etc/profile (. Followed by a space)
Personal home directory:
[jepson@ruozehadoop001 ~] $ll-a (view hidden files)
Total 28
Drwx-. 4 jepson jepson 4096 May 19 05:36.
Drwxr-xr-x. 3 root root 4096 May 19 05:36..
-rw-r--r--. 1 jepson jepson 18 Jul 18 2013 .bash _ logout
-rw-r--r--. 1 jepson jepson 176 Jul 18 2013 .bash _ profile
-rw-r--r--. 1 jepson jepson 124 Jul 18 2013 .bashrc
[jepson@ruozehadoop001 ~] $vi .bash _ profile (edit .bash _ profle, generally speaking, engineers will choose one of the .bash _ profile and .bashrc files for editing, the main file)
Alias tmp='cd / tmp'
[jepson@ruozehadoop001 ~] $source .bash _ profile
Personal habits:
[jepson@ruozehadoop001] $. .bash _ profile
7.su switching user
-Parameter indicates switching user
Execute the jepson user's environment variable file and enter the home
[root@ruozehadoop001 ~] # su jepson (to the root directory of jepson individual users)
[jepson@ruozehadoop001 root] $
[jepson@ruozehadoop001 root] $pwd
/ root
[jepson@ruozehadoop001 root] $
[root@ruozehadoop001 ~] # su-jepson (to the home directory of individual jepson users)
[jepson@ruozehadoop001 ~] $
[jepson@ruozehadoop001 ~] $pwd
/ home/jepson
[jepson@ruozehadoop001 ~] $
8.vi
Command I to edit shift+: to enter the trailing line
Edit body ecs exit to command
Trailing wq saves wq! Force save exit Q! Forced exit
Ordinary 9.sudo users have temporary root permissions
[jepson@ruozehadoop001 ~] $ll / root
Ls: cannot open directory / root: Permission denied
[root@ruozehadoop001 ~] # vi / etc/sudoers (change the permissions in sudoers so that jepson has root permissions)
Jepson ALL= (root) NOPASSWD:ALL
[jepson@ruozehadoop001 ~] $sudo ll / root
Sudo: ll: command not found
[jepson@ruozehadoop001] $sudo ls-l / root (ll is not available here, but the full name ls-l is OK)
Total 120
-rw-. 1 root root 1382 Apr 28 05:56 anaconda-ks.cfg
Drwxr-xr-x. 2 root root 4096 May 19 21:40 Desktop
Drwxr-xr-x. 2 root root 4096 May 19 21:40 Documents
Drwxr-xr-x. 2 root root 4096 May 19 21:40 Downloads
-rw-r--r--. 1 root root 49565 Apr 28 05:55 install.log
-rw-r--r--. 1 root root 10033 Apr 28 05:51 install.log.syslog
Drwxr-xr-x. 2 root root 4096 May 19 21:40 Music
Drwxr-xr-x. 2 root root 4096 May 19 21:40 Pictures
Drwxr-xr-x. 2 root root 4096 May 19 21:40 Public
Drwxr-xr-x. 4 root root 4096 May 20 14:32 ruozedata
-rw-r--r--. 1 root root 13 May 19 23:07 ruoze.log
-rw-r--r--. 1 root root 34 May 19 23:06 ruoze.log1
Drwxr-xr-x. 2 root root 4096 May 19 21:40 Templates
-rw-r--r--. 1 root root 17 May 19 22:55 test.log
Drwxr-xr-x. 2 root root 4096 May 19 21:40 Videos
[jepson@ruozehadoop001 ~] $
10. Users and user groups
[root@ruozehadoop001 ~] # ll / usr/sbin/user* (* for all, view all users)
-rwxr-x---. 1 root root 103096 Dec 8 2011 / usr/sbin/useradd
-rwxr-x---. 1 root root 69560 Dec 8 2011 / usr/sbin/userdel
-rws--x--x. 1 root root 33952 Aug 23 2010 / usr/sbin/userhelper
-rwxr-x---. 1 root root 98680 Dec 8 2011 / usr/sbin/usermod
-rwsr-xr-x. 1 root root 9000 Nov 23 2013 / usr/sbin/usernetctl
[root@ruozehadoop001 ~] # ll / usr/sbin/group* (* for all, view all user groups)
-rwxr-x---. 1 root root 54968 Dec 8 2011 / usr/sbin/groupadd
-rwxr-x---. 1 root root 46512 Dec 8 2011 / usr/sbin/groupdel
-rwxr-x---. 1 root root 50800 Dec 8 2011 / usr/sbin/groupmems
-rwxr-x---. 1 root root 61360 Dec 8 2011 / usr/sbin/groupmod
[root@ruozehadoop001 ~] # id jepson (view jepson)
Uid=500 (jepson) gid=500 (jepson) groups=500 (jepson)
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] # useradd ruoze creates a user and user group with the same name
[root@ruozehadoop001 ~] # id ruoze
Uid=501 (ruoze) gid=501 (ruoze) groups=501 (ruoze)
[root@ruozehadoop001 ~] #
Gid: primary group
Groups: all groups
[root@ruozehadoop001 ~] # ll / home/
Total 8
Drwx-. 4 jepson jepson 4096 May 20 15:08 jepson
Drwx-. 4 ruoze ruoze 4096 May 20 15:14 ruoze
[root@ruozehadoop001 ~] # userdel ruoze (delete user command)
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] # id ruoze
Id: ruoze: No such user
[root@ruozehadoop001 ~] # ll / home/ (ruoze users have been deleted not detected in home)
Total 8
Drwx-. 4 jepson jepson 4096 May 20 15:08 jepson
Drwx-. 4 501 501 4096 May 20 15:14 ruoze
[root@ruozehadoop001 ~] #
Create again
[root@ruozehadoop001 ~] # useradd ruoze
Useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Creating mailbox file: File exists (because home does not detect that the ruoze user has been deleted, it will report a duplicate problem)
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] # cat / etc/passwd (printer user)
[root@ruozehadoop001 ~] # cat / etc/group (print user group)
[root@ruozehadoop001] # usermod-a-G bigdata ruoze (add a bigdata user to ruoze)
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] # id ruoze
Uid=501 (ruoze) gid=501 (ruoze) groups=501 (ruoze), 502 (bigdata)
[root@ruozehadoop001 ~] #
11. Pipe symbols and filtering
[root@ruozehadoop001 ~] # cat / etc/passwd | grep jepson (take | the previous result as the output of the following instruction, filter the result through grep to get the final result, here is only the passwd of jepson)
Jepson:x:500:500:ruozedata:/home/jepson:/bin/bash
[root@ruozehadoop001 ~] #
twelve。 Process and port number
[root@ruozehadoop001 ~] # ps-ef | grep ssh (check the port number of ssh)
Root 1480 1 0 14:03? 00:00:00 / usr/sbin/sshd
Root 1819 1480 0 14:07? 00:00:00 sshd: root@pts/0,pts/1,pts/2,pts/3
Root 2286 1823 0 15:34 pts/0 00:00:00 grep ssh
[root@ruozehadoop001 ~] #
User pid
Root 1480
[root@ruozehadoop001 ~] # ps-ef | grep http
Root 2820 1 0 15:40? 00:00:00 / usr/sbin/httpd
Apache 2823 2820 0 15:40? 00:00:00 / usr/sbin/httpd
Apache 2824 2820 0 15:40? 00:00:00 / usr/sbin/httpd
Apache 2825 2820 0 15:40? 00:00:00 / usr/sbin/httpd
Apache 2826 2820 0 15:40? 00:00:00 / usr/sbin/httpd
Apache 2827 2820 0 15:40? 00:00:00 / usr/sbin/httpd
Apache 2828 2820 0 15:40? 00:00:00 / usr/sbin/httpd
Apache 2829 2820 0 15:40? 00:00:00 / usr/sbin/httpd
Apache 2830 2820 0 15:40? 00:00:00 / usr/sbin/httpd
Root 24478 1823 0 15:44 pts/0 00:00:00 grep http
[root@ruozehadoop001] # kill-9 2820 Kill 1 (but not the latter)
[root@ruozehadoop001] # kill-9 $(pgrep-f httpd) all about httpd
[root@ruozehadoop001 ~] # ps-ef | grep http
Root 25285 1823 0 15:46 pts/0 00:00:00 grep http
[root@ruozehadoop001 ~] #
Where rm and kill, first determine whether to delete and kill, their rm-rf / do not use
Confirm clearly before the execution of its kill command
[root@ruozehadoop001 ~] # netstat-nlp | grep 1480 (check the process with port number 1480)
Tcp 0 0 0.0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0
Tcp 0 0: 22:: * LISTEN 1480/sshd
[root@ruozehadoop001 ~] #
Thinking questions:
The xxx web service interface of that computer?
Ip: ifconfig of xxx service
Port number: ps-ef | grep xxx (check the port number based on the process name) netstat-nlp | grep pid (check the process name by the port number)
13.yum install rpm
[root@ruozehadoop001 ~] # yum install httpd
[root@ruozehadoop001 ~] # service httpd start (pay attention to the corresponding DNS and close the arson wall when the network is down)
Query
[root@ruozehadoop001 ~] # rpm-qa | grep http
Httpd-tools-2.2.15-60.el6.centos.6.x86_64
Httpd-2.2.15-60.el6.centos.6.x86_64
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] #
Unloading
[root@ruozehadoop001] # rpm-e httpd-tools-2.2.15-60.el6.centos.6.x86_64
Error: Failed dependencies:
Httpd-tools = 2.2.15-60.el6.centos.6 is needed by (installed) httpd-2.2.15-60.el6.centos.6.x86_64
[root@ruozehadoop001 ~] #
Do not check
[root@ruozehadoop001 ~] # rpm-e-- nodeps httpd-tools-2.2.15-60.el6.centos.6.x86_64 (mismatch dependency)
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] #
[root@ruozehadoop001 ~] # rpm-qa | grep http
Httpd-2.2.15-60.el6.centos.6.x86_64
[root@ruozehadoop001 ~] #
At this point, the study of "what are the commonly used commands in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.