Common linux Commands

Source: Internet
Author: User
: String downward query string content n next :? Character to search for string content n the next cursor moves to the row to be copied, enter y

:/String downward query string content n Next
:? Character to search for the string content n Next
Move the cursor to the row to be copied, enter yny (n indicates n rows below the row to be copied), move the cursor to the paste row, and press p to paste.

To upgrade or install any program in Linux, you must first uninstall the old version and then uninstall it. This will avoid unexpected troubles.

Save the editing result and restart the network service.
/Etc/init. d/networking restart

Vi file name q exit w save q! Force exit wq! Save force exit
In the command mode of VI, enter ": set nu", and the row number is displayed.

./Startup. sh; tail-f ../logs/catalina. out

Rpm-ivh jdk-7u40-linux-i586.rpm ivh displays the installation process
(1) install jdk
Set environment variables
# Vi/etc/profile
Add the following content at the end
Set JAVA_HOME =/usr/java/jdk1.7.0 _ 40
Export JAVA_HOME
Set PATH = $ JAVA_HOME/bin: $ PATH
Export PATH
Set CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export CLASSPATH
# Javac-version

Export JAVA_HOME =/usr/java/jdk1.7.0 _ 40
Export CLASSPATH =.: $ JAVA_HOME/jre/lib: $ JAVA_HOME/lib/tools. jar
Export PATH = $ JAVA_HOME/bin: $ PATH

(1) modify the/etc/profile file-valid for all users
Add at the end of the profile file
JAVA_HOME =/usr/java/jdk1.5.0 _ 16 -- jdk installation path
PATH = $ JAVA_HOME/bin: $ PATH
CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export JAVA_HOME
Export PATH
Export CLASSPATH
Export CATALINA_HOME
Save and exit
Input source/etc/profile in shell
If an error is reported when you run the preceding command, check whether the text you added in/etc/profile is incorrect.
No error detected. log on again.

(2) install Tomcat
# Wget http://mirror.bjtu.edu.cn/apache/tomcat/tomcat-7/v7.0.16/bin/apache-tomcat-7.0.16.tar.gz
# Tar-zxvf apache-tomcat-7.0.14.tar.gz
# Mv apache-tomcat-7.0.14/usr/local/www/tomcat
# Vi/usr/local/www/tomcat/bin/catalina. sh

1. disable the firewall service in the virtual machine. Desktop-Management-security level and firewall: Set the firewall to disable. Or, run

Service iptables stop -- stop

Service iptables start -- start

However, in practical applications, firewall is disabled to reduce the security of the server.
If you telnet the VM's 8080 window in the dos window of the host machine, it will fail. it can be determined that the VM's 8080 window is faulty and should be blocked by the firewall. Modify the firewall settings.

2. modify the/etc/sysconfig/iptables file to modify the firewall configuration of the Linux system. if you want to open a port, add
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 8080-j ACCEPT
8080 is the port number to be opened, and then restart the firewall service in linux,
/Etc/init. d/iptables restart.

CSH: setenv name value
BASH: export name = value

CSH: unsetenv name
BASH: unset name

Command: chmod (change mode)
Function: change the read/write and execution permissions of a file. The signed method and the octal digit method.
Option: (1) Symbolic method:
Command format: chmod {u | g | o | a} {+ |-| =}{ r | w | x} filename
U (user) indicates the user himself.
G (group) indicates the same group of users.
O (oher) indicates other users.
A (all) indicates all users.
+ Permission granted to a specified user.
-Cancels the permission granted to a specified user.
= Grant the permitted permissions to the file.
R (read) indicates that the content of the file or directory can be copied.
W (write) write permission indicates that the content of the file or directory can be modified.
X (execute) indicates that you can execute the file or enter the directory.
Chmod g + rw a.txt

Useradd-g test-d/home/test1-s/etc/bash-m test1
Note: SHELL used by-g Group-d home directory-s
Delete user commands
Useradd

Ls/usr/lib/libz *
Normally, you should see
Libz. so
Libz. so.1
Libz. so.1.y. z
Among them, libz. so.1.y. z is the real library file, and 1. y. z is the specific version. if your libz. so.1.y. z is still running, you can
Ln-s/usr/lib/libz. so.1.y. z/usr/lib/libz. so.1

Ecport LANG = zh_CN.utf-8
Or modify/etc/sysconfig/i18n.

Apache runs as a specific user, such as a www-data user.
Gitolite version libraries cannot be accessed on gitweb, which is often a permission issue.
One of the two methods is to configure suexec to run gitweb as a git User, and the other is to add apache users to the git group,
You also need to set the git version Library g rx. Google.
Vi apache2/conf/httpd. conf # Modify the httpd. conf file
Set
User daemon
Group daemon
Change
User root // git User Group
Group root // git User rent
Save and exit

After a long time, rhel5 took 1.4 and found many deletion methods. Later I used a hero's:
Yum remove java is OK, haha

Ssh-keygen-generate, manage, and convert authentication keys, including RSA and DSA keys
You can use the-t option to specify the key type. If not specified, the RSA key for SSH-2 is generated by default

------------------- Book content starts ----------------------------------

Sudo: Run as root
Su: escalate to root

Sudo apt-get update: updates the current system software package information from the internet

Pwd: displays the current path
Cd or cd ~ Return to the current user directory
Ls-F (another display method)-a (display all files)-l (display file details)-ld (display folder details, followed by the folder name)

---------------------- View file content --------------
Cat-n (number of displayed rows)
More B: move the button forward, flip the page with a space, and press the button backward.
Tail: indicates the end of the file.-f indicates full tracking.
Head: The header of the file-n: the number of rows before the specified number.
Less replaces more to search for specified content using/+ text

Name or directory of the content to be queried by grep (separated by spaces)
Find is used to find files

---------------------- View file content --------------

----------------------- System User Information --------------------------
Who displays all current login users
Whoami displays the current logon user
Uname-a Displays system information
Uname-r: displays system kernel information
Sudo useradd-G user name User group name
----------------------- System User Information --------------------------

------------------------ Command information ----------------------------------
Whereis is used to find program files
Man + Command: displays the Command Manual
Whatis + Command: displays the introduction of this command
Apropos: displays all commands.

Prompt $ indicates running as a non-root user # indicates running as a root user
------------------------ Command information ----------------------------------

------------------------ About starting an application -------------------------------

You can add & after the program name, such as firefox, to continue running in the background.

------------------------ About starting an application -------------------------------

------------------------------------------ File folder-related content -----------------------------------------------
Mkdir: create a folder.-p indicates creating folders that do not exist.

Touch creates an empty file and refreshes the last update time

Mv-I (ask me if there is the same file name when moving)-B (it means that the existing file will not be overwritten, but the existing file will be renamed as the original file name ~ Format)
Cp-I (same as mv)-B (same as mv)-r (copied together with sub-files)
Rm-I (prompt whether to delete)-f (indicates that you do not need to ask whether to delete the common file. by default, the common file will prompt whether to delete it)-r (same as cp)

Sudu chown-R (same as cp) user name: User rent file/folder
Sudu chown User Name File // modify user name separately
Sudu chown: User Group Name File // modify user group separately
Chmod u + x file name // u: file owner g: file Group o: others a: Owner +: add permission-: delete permission
Chmod ug = rw, o = r, o = u file name // ug permission: read/write, o permission: Read, Grant u permission to o

Ln-s (indicating soft connection) without-s indicates hard link

Output redirection:> directly overwrite the content of the following file> indicates appending to the following file
Input redirection: cat <file name // use the content in the file name as the input of cat
Cat <EOF // wait until you enter the EOF

Pipeline: | indicates the previous output, which is the input of the subsequent command


The ls-l permission is composed of o (owner) rwx g (user group) rwx o (others) rwx.
------------------------------------------ File folder-related content -----------------------------------------------

-------------------------------------------------- Program installation and uninstallation ------------------------------------------------------
Package Type:. deb. rpm
Source code installation file extension: .tar.bz2 or tar.gz
Command step for source code installation
First:./configure -- prefix =/usr/loca/+ custom Directory // check whether the current system meets compilation conditions to generate makefile FILES required for compilation
Second:./make // compile the source code
Third:./make install // install software to the hard disk

Dpkg-I (software installation) -- force (force installation is not recommended)
Dpkg-l show all installed software packages
Dpkg-S software package name // query which files have been copied to the system by the software package
Dpkg-r package name // indicates uninstall the package

Rpm-ivh (installation package) -- force (same as dpkg)
Rpm-Uvh (with the new software package) package name version
Rpm-q package name // displays the version information of the package
Rpm-qa // display all installed software packages
Rpm-e package name // uninstall the package without the version number plus -- nodeps indicates forced uninstall

Advanced Software package management tool yum APT, among which APT is the most mature

Apt-get update: This is the first time the system is started for use. it updates the package information in the current apt-get cache.
Apt-get install: Download and install the software package
Apt-get clean: delete all downloaded software packages
Apt-get remove: delete the specified software package
Apt-get source: download the source code of a specific software package.
Apt-get upgrade: Download and install the latest software package on the system.
Apt-cache search name // indicates the specific software package to be searched by name
Depents software package // display all the software packages that come from this software package
Configure apt-get in/etc/apt/sources. list
-------------------------------------------------- Program installation and uninstallation ------------------------------------------------------

------------------------------------------------- Disk management -----------------------------------------------
Swap partition capacity, which should not exceed 2 GB
Mount: sudo mount-r (read-only) w (read/write mounting, default)/dev/cdrom (device folder)/mnt/cdrom (computer folder) // Mount command
Sudo umount/dev/cdrom (device folder) // uninstall command
All device files are stored under/dev.

 

Df // displays statistics of all mounted file systems
Df-t folder // add-t to display only the following file system Statistics
------------------------------------------------- Disk management -----------------------------------------------

-------------------------------------------------------- Compression & decompression & packaging ---------------------------------------------------
Gzip linux.tar // then it becomes linux.tar.gz compressed
Gunzip-l (show the decompression process effect) linux.gz // Extract
Gzip-TV linux.tar.gz // check the integrity of the compressed package

Bzip2 linux.tar // Convert it to linux.tar.bz2 for compression
Bunzip2 linux.tar.bz2 // Extract
Bzip2-TV linux.tar.bz2 // check the integrity of the compressed package

Tar-cvf linux.tar shell // package the shell folder into linux.tar
Tar-xvf linux.tar // unpack
Tar-czvf linux.tar.gz shell // package the shell and compress it with gzip
Tar-xzf linux.tar.gz // decompress the package with gzip and then decompress the package with tar
-------------------------------------------------------- Compression & decompression ------------------------------------------------------------

----------------------------------------- User & User Group -----------------------------------
Useradd-m (if there is no m, the user's main directory will not be created, you cannot use this account to log on to the graphical interface) cuiyaonan
Useradd-g cuiyaonan // use g to specify a user group
Useradd-s/bin/bash cuiyaonan // use s to specify a specific shell

Userdel cuiyaona // delete a user
Userde-r cuiyaonan // delete the user directory at the same time

/Etc/passwd // basic information of all users
/Etc/shadow // password information of the user
/Etc/group // all user group information
/Ect/gshadow // The user password is useless.

Usermod // manage users in a hundred degrees ......

Id username // indicates the user's information. if the user name is not included, the user's information is viewed.

Groupadd cuiyaonan // resume User Group

History // view the user's recently used commands stored in the. bash_history user directory

----------------------------------------- User & User Group -----------------------------------

------------------- End of book content ---------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.