Goal
Master some of the basic Linux commands
Mastering Linux common system Management commands
Learn the installation of everyday software
Publish a Web project inside a Linux system
Body
User account File-passwd
PASSWD is a text file that defines the user account for the system, which is located in "/etc/passwd". It contains a list of system accounts and gives some useful information about each account. Each row in the passwd file defines a user account, and a row with multiple fields separated by ":"
Account |
Account name |
Password |
account password, for security reasons, now do not use this field to save the password, but with the letter "x" to populate the field, the real password is saved in the shadow file. |
Uid |
User ID number, the only number that represents a user. |
Gid |
The private group number to which the user belongs, which corresponds to the GID in the group file . |
GECOS |
This field is optional and is typically used to hold user-named information. |
Directory |
The user's home directory, the default directory after the user successfully logs on. |
Shell |
The shell used by the user , such as the word blank, uses "/bin/sh". |
User group Files-group
User groups are a convenient way to logically organize user account collections, which allows users to share files within a group. Each file on the system has a user and owner of a group.
Each group on the system has a row of records in the/etc/group file, with four fields per line.
Group name is the name of the set
Encryption password for passwd group
GID system distinguishes between different groups of IDs
The user list is a "," separate username that lists the members of this group.
Groupadd, Groupdel
The Groupadd command is used to create a new group
Example: Groupadd mygroup
Groupdel command to delete a group
Example: Groupdel mygroup
Useradd
Useradd is used to add users.
Command format: Useradd user
Add a row of records in the/etc/passwd file, create a new user's home directory under the///directory, and copy the files from the/etc/skel directory to the directory, the user cannot log in, and must set the password setting password before landing.
When a new user is added, the system creates a group with the same user name as the user. This approach is intended to allow new users to isolate themselves from other users and to ensure security measures.
If you feel that the above build user is not very good, for example: Also to set the password, you can consider using Useradd with parameters to create the user:
Useradd xxx-g xxx-d/home/xxx-m-s/bin/bash |
Using this method to set up the user, the group is set, the user home directory, the shell is specified, and the password.
Usermod
The Usermod command can be used to modify various properties of a user account, including user home directories, private groups, logins, shells, and so on.
The parameters of the Usermod command are as follows:
-G |
Modify the group in which the user name is located. |
-L |
Modify the user name. |
-L |
Lock the user account. |
-U |
Unlock the user account. |
Usermod-g the group name account to be modified
Usermod-l the account to be modified after the modified account
Usermod–l the account you want to lock
Usermod–u the account to unlock
Userdel
Userdel User Delete user, syntax format:
Userdel [-R] [account to be deleted]
Without the parameter "R" Delete account will only delete the account, and this account home directory files are not deleted, if you delete the account also delete the file using "-R".
passwd
The PASSWD command is used to set or modify the password for the user name, the command format is: Passwd [user name]
Only Superuser can use "passwd username" to modify other user's password, ordinary users can only modify their own password with the passwd command without parameters.
In addition, the passwd command can also use some parameter options, which can be used to perform different operations on the password of the account, but these passwd commands with parameters are available only to the root user. These parameter choices include:
-S |
Used to query the status of the specified user account. |
-L |
Password to lock the account |
-U |
Unlock the password for the account. |
-D |
Deletes the password for the specified account. |
Who am I &whoami
[Email protected] ~]$ Whoam I
The system only echoes the user's own registration information.
[Email protected] ~]$ WhoAmI
You can also return information for a user.
ID, Su, groups
The ID command is used to display the user's current Uid,gid and the group list of the owning group the syntax format of the directive is:
ID [options] [user name]
The SU command is used to convert the current user to another user identity.
Su [-][user account]
-Change the working directory as well as home,shell,user,logname when changing identities. In addition, the path variable is changed.
The Groups command displays the group to which the specified user belongs, and displays the group to which the current user belongs, if no user is specified.
PS, kill
The most common use of PS commands is to monitor the work of the background process.
The command syntax format is as follows: PS [options]
-E |
Show all processes. |
-F |
Full format. |
-H |
The caption is not displayed. |
-L |
Give a long list. |
-A |
Displays all processes on the terminal, including the processes of other users. |
-R |
Only the processes that are running are displayed. |
-U |
Print user format, display user name and start time. |
In general, you can use the Ps–ef to view.
The KILL command can terminate a background process. After you query the process ID with the PS command, you can force the shutdown process through the kill command.
kill-9 PID (forced shutdown of a process)
chmod
chmod command to change the file permission bit settings.
the general format of the chmod command is:
chmod [who] operator [permission] filename
Who's meaning is:
U: the file belongs to the master permission.
G: same group of user rights.
O: Other user rights.
A: All users (file owner, same group of users and other users).
operator the meaning of:
+: increase permissions.
-: Cancel permissions.
=: set permissions.
Permission the meaning of:
R: Read permissions.
W: Write permission.
X: Execute permissions.
chmod Instances
Chown is used to change the owner of a file or directory, that is, to give its ownership to another/etc/passwd file in the presence of a legitimate user. For security reasons. Only system administrators can change the ownership of files.
The general form of the Chown command is:
Chown-r-H owner File
The-h option means that the change-r option means that all subdirectories under the same action number are also made to the owner of the linked file does not affect the target file that the link points to.
The function of the CHGRP command is to change the group of files. The CHGRP command is the same format as the Chown command.
Ifconfig
Ifconfig Ech0 Stop
Ifconfig ech0 up
Ifconfig eth0192.168.204.135 netmask 255.255.255.0
ln
LN is used to set the link, which is similar to a shortcut in Windows
The general form of the command is:
ln [-S] source_path Target_path
Cron and Crontab
Cron is the main scheduling process for a system that can run jobs without human intervention. There is a command called Crontab that allows the user to submit, edit, or delete the corresponding job. Each user can have a crontab file to hold the dispatch information. To be able to run a job at a specific time, you need to understand the meaning and format of each field in each entry in the C R o n ta b file.
Here are the fields:
1th Column min 9
3 in the 2nd hour (0 means midnight)
3rd Liege 1
4th Column Month 1~1 2
5th Column Week 0~6 (0 = Sunday)
6th List of commands to run
Crontab Command Options
The general form of the crontab command is:
crontab [-u user]-e-l–r
which
-u user name.
-e Edit the crontab file.
-l lists the contents of the crontab file.
-R Delete the crontab file.
Crontab instances
Find
Find is a very efficient command that can traverse the current directory and even the entire file system to find certain files or directories.
The general form of the Find command is:
Find Pathname-options [-print-exec-ok]
The directory path that the Pathname:find command looks for. For example, use. To represent the current directory, and/to represent the system root directory.
The-print:find command outputs the matched file to standard output.
The-exec:find command executes the s H e l command given by the parameter to the matching file. The corresponding command is in the form of ' Comm-and ' {} \;, note the space between {} and \;
-ok: And-exec function the same, but in a more secure mode to execute the parameters given by the shell command, before executing each command, will give a prompt for the user to determine whether to execute.
Find Command Options
The Find command has a number of options or expressions, followed by a horizontal bar before each option. Let's take a look at the main options for this command first.
-name finds files by file name.
-perm to find files according to file permissions.
-user Search for files according to the owner of the file.
-group finds files according to the group to which the files belong.
-type find a file of a certain type, such as:
B- block device files.
D- directory.
C- character device file.
P- pipeline file.
L- Symbolic link file.
F- normal file.
-size N[c] finds files with a file length of n blocks, with C indicating the length of the file in bytes.
-depth when looking for a file, first find the file in the current directory, and then look in its subdirectories.
Find Command Instance
Find/-name "MySQL"
find/usr/local/mysql/-name "*.sh"
Find/-user Sinoyang–print
Find/-group class106
find/home/sinoyang/-type D
find/home/sinoyang/-type F
Find logs/-name "*.log"-exec rm-rf {} \
Grep
grep ' 8080 ' server.xml
grep ' 8080 '-v server.xml
Grep-n ' 8080 ' server.xml
Grep-c ' 8080 ' server.xml
grep ' ^$ ' –cserver.xml
grep "SSH" ~/-rn
Awk
cat/etc/passwd | Awk-f: ' {print '} '
rsync [Email protected]:~/test.sh~/
Rpm
RPM–IVH mysql-client-5.1.7-0.rpm
Rpm-qa | grep MySQL
Rpm-qa | Grep-i MySQL
Rpm–e
Tar
Tar is used to compress the extracted files
TAR–ZXVF xxx.tar.gz Decompression
TAR–ZCVF xxx.tar.gz XXX Compression
Other commands
Free–m Viewing memory conditions
Top View CPU Usage
Df–h viewing hard disk usage
Du–sh Statistics Directory Size
Service Iptablesstop/start Enable/disable firewall
Service Mysqlstop/start turn on/off MySQL
Cat/etc/issue Viewing the system version
cat/etc/passwd | Wc–l the number of rows in the query file
Installing the JDK
Unzip the JDK installation file
./jdk-6u13-linux-i586.bin
Configuring Environment variables
Modified. Bash_profile
Set environment variable to take effect
source. bash_profile or log off to log back in.
Installing Tomcat
Unzip the Tomcat installation file
TAR-ZXVF apache-tomcat-7.0.2.tar.gz
Modify shell File Execution Permissions under the $tomcat/bin directory
chmod u+x *.sh
Start Tomcat
./startup.sh
See If Tomcat starts well
Ps-ef | grep Tomcat
Close Tomcat
Linux Common commands