Linux Command Learning

Source: Internet
Author: User

#mount/DEV/CDROM/MNT/CDR the/dev/cdrom cdrom mount the/MNT/CD directory
mkdir Creating a Directory
RmDir Delete directory (only directories that are empty are deleted)
RM-RF recursively delete directories or directories (R is recursive, false, not queried, directly deleted)
Touch to create an empty file.
LS lists all directories and files in the current directory
Ls-l detailed display/MNT/CD The first letter is D for the table of contents, and for-represents the link for the file l
Ls-r by tree-like interface
PWD Displays the location of the current directory
CD Switch Directory
Unmount/mnt/cd
CD/Return root directory
Cd.. Return to Parent Directory
Cd. Current path
Exit Termial
Shutdown shut down the machine
Reboot restart
Logout logoff
Q
CTRL +c ends the currently running command
Ctrl+d

Shutdown--Help
Shutdown--? These two commands will show the use of shutdown
Man shutdown will show the use of shutdown in detail

CP A B copies a to B
Cp-r D1 D2 The directory D1 recursively copy C into D2
MV DD1 D2 move DD1 to D2
VI Text Editor
VI 3.txt Edit 3.txt (if 3.txt is not created, there is edit)

Drwxr-xr-x
chmod +x testfile Add executable permissions to testfile files
-X Reduce executable permissions
chmod 755 testfile Add read and Execute permissions to testfile files
Chown TestUser2 testfile Modify Testfile's owner to TestUser2
WC statistics Specifies the number of lines, words, and characters of a text file


How to convert the command mode to edit mode under VI
W Disk
Q exit
Q: Do not save the disk to exit
Wq Save exit
DD Delete entire row
DW Delete Whole Word
o Insert a row
O Insert a row upwards


Cat 3.txt is serialized out 3.txt of content
TAC 3.txt Reverse sequence out of 3.txt content
More 3.txt lists 3.txt of content
Head-n 3.txt list file 3.txt top n rows
Tail-n 3.txt list file 3.txt after n rows
Clean screen
Find File
Find/etc-name *local
Grep finds the specified string in the specified text file
grep abcdef File1 Find the string containing abcdef in the File1 file
Whereis command name
Echo $PATH the contents of the train PATH variable
The delimiter for Linux is a colon (:)
ln links
ln 3.txt 4 Creates a 3.txt link of 4, so viewing 4 of the content and 3.txt, modify 3.txt will affect the content of 4 (hard connect is equivalent to copy the file and establish a link in this file)---Delete 3.txt view 4 content will exist
Ln-s 3.txt 5 (soft link equivalent to Windows shortcut) modify 3.txt will affect 5 of the content-delete 3.txt View 5 of the content will not be

Whereis

Useradd or adduser LSF increased user LSF
PASSW LSF assigning passwords to LSF users
Groupadd gtest Add user group to Gtest
Usermod-g gtest LSF modifies the group of LSF,
Userdel Deleting a user
Su LSF Switch user to LSF
When a new user logs on, the current directory is the user's home directory
FDISK-L Display of disk information
Du displays the total amount of disk space used by the specified file/directory
DF shows the use of file system disk space
Locale Displays the current locale

Pipe symbol |
ls-rl/etc | More lists the contents of the/etc directory and displays it in pages (the space will be paged)
CAT/ETC/PASSWD |WC Lists the contents of the/etc/passwd and counts the number of rows in the content

Mans Bash|col-b>bash.txt

Col Filter control characters
Ls-l | grep "^d" (^ denotes the beginning of a line.) d = directory) List only
ls-l* | grep "^-" |wc-l lists the files and counts the number of rows: Figure out how many files are in the current directory
Wall (warning all) warns everyone
Wall ' Date ' (' The character to the left of the number key 1): warns all people that the content is a replacement for date
REDIRECT output:
ls > Cmd.txt outputs the results of LS execution to Cmd.txt
LS >> cmd.txt
REDIRECT Input
Wall < Aa.txt aa.txt input as a warning to all people
How to modify the system's default boot level

Installing the Samba server program under Linux allows sharing of files between Linux and Windows systems (less, because two systems are not on the same LAN)

The best way to do this is to build an FTP serever under Linux and upload it via windows
FTP command exit by: bye
Ifconfig Display IP configuration information


Chkconfig--level 5 vsftpd on set VSFTPD service on boot
Chkconfig--list |grep vsftpd Find out what's chkconfig in the list in VSFTPD

RET Hat Linux Default FTP is VSFTP and can be logged in to vsftp anonymously
Default command line Startup: Modify the Inidefault of the Initab file
telnet to Linux: SSH is more secure than telnet using the SSH service. Need to use SSH client (Putty Client is recommended, right-click to paste after selection)

Install JDK: File extension bin (JDK 1.6.bin to modify permissions such as: chmod 755 jdk 1.6.bin to make the JDK have execute permissions and then use./JDK 1.6.bin to install the default installation in USR's Java file)

Compressed file with tar.gz extension can be decompressed with tar or gzip (giz-d; tar-xvf)
You can use the MV rename: for example: MV Testfile file is renamed to file
You can specify java_home=/usr/java/jdk1.6.0_03 directly

Export java_home: Export the Java_home to all users
PS observe which processes are below
Ps-ef|grep Tomcat to see if the Tomcat process is started
Sevices iptables Stop Stop Firewall

Ubun Stop the Firewall terminal input: sudo ufw disable
Kill-9 2724 (2724 for Tomcat process ID number) forces the KILLTOMCAT process

Red Hat Linux command line internet: wget http://localhost:8080

RPM-QA lists all installed packages installed in the Linux environment
Rpm-qa |grep JDK to see if the JDK is installed
RPM-E jdk1.6 Uninstalling the JDK
RPM with additional parameters can also be forced to unload
RPM-IVH jdk1.6-i586.rpm Installation jdk1.6

How do I set java_home as a global variable?
1, can be set under the Rc.local
2 in VI edit/etc/profile last migration Direct assignment java_home=/usr/java/jdk1.6.0_03
Export Java_home This way, Java_home is working.
Linux in the. The file that starts is the hidden file.
echo $JAVA _home to view variable values
How do I set up tomcat boot from?
can be modified with VI/etc/rc.local
Java_home=/usr/java/jdk1.6.0_03
Export Java_home
/tomcat5/bin/startup.sh


Reboot restart
Mount
Install MySQL first install MySQL server
Linux Case sensitive
mysql command: show databases
Deploy an OA project to Linux
Let MySQL start automatically: service MySQL start
Chkconfig--list |grep MySQL

Apach +tomcat Load Balancing
-----------------------
-----------------------
Hanshunping Lecture Notes:
1. See which Shell is currently used
Env This command can display the environment variables of the current operating system
command to modify the shell: Chsh-s Enter a new shell such as:/bin/csh
Command completion: Enter MK and press the TAB key to display all commands starting with Mk. can complete the corresponding command name
Lookup History Commands:
1.history 5: This description shows the 4 most recently used commands
2.! 5: This description executes a command with a history number of 5
3,! LS: This description executes the last command that starts with "LS"

Trace route: Tracert www.baidu.com now reaches the number of routes traversed by www.baidu.com and IP for each route
Ping ip/URL to test whether the machine and the other machine are unblocked

The command to view the IP condition in Windows is ipconfig
The command to view the IP condition under Linux/unix is ifconfig
Network Environment configuration:
1. Write the setup graphical configuration at the command line.
Then execute the following command
/etc/rc.d/init.d/network Restart is the NIC's configuration effective
2.ifconfig eth0 192.128.88.88 Set network card address
Ifconfig eht0 Network x.x.x.x subnet mask settings
Use the default for broadcast addresses and DNS.
Note: The above ifconfig configuration of the network will take effect immediately, but it is temporarily in effect, after the shutdown restart the configuration expires.
In Linux, all settings are file
3./etc/sysconfig/network-scripts/ifcfg-eth0 in this file can modify the IP, subnet mask, broadcast address, default gateway.
However, the configuration of the NIC does not take effect at this time, you need to run/etc/rc.d/network Restart command to make the above configuration effective. After the entry into force, this modification is permanently modified

RPM Management-rpm Common commands
Rpm-qa query which RPM software is installed in Linux
rpm-q mysql query if MySQL RPM package is installed
Installing RPM Packages
Rpm-i RPM Package Full path name: Install package to current system (I=install)
RPM-IVH RPM Package Full path name: Install package to current system with prompt information (i=install,v=verbose hint, h=hash progress bar)

RPM Package Removal
The name of the RPM-E RPM package (if the unloaded package depends on the other package, the uninstallation generates an error message)
eg. RPM-E JDK
RPM-E--Nodeps Samba forced offload samba includes dependent packages

Rpm-q Samba to see if Samba is installed
Set up a Samba password file
Users who turn Linux users into samba: cat/etc/passwd |mksmbpasswd.sh >/ETC/SAMBA/SMBPASSWD
Set up the LSF user's samba password: smbpasswd LSF
Start Samba server: Service SMB start
To stop ... the end of a. ... stop.. stops. .....

Set Task Dispatch command CRONTAB-E
Crontab-r terminating task scheduling (R=remove)
Cronrab-l: Lists which tasks are currently scheduled
Ps-a: Displays all process information for the current terminal
Ps-aux: Full display of all process information for the current terminal
Kill process Number: Terminate process
Kill-9 process Number: Forcing the process to terminate
Top: Process dynamically monitors all process information
TOP-D 10: System Update time is 10 seconds
Netstat: command to display network statistics
Netstat-an
NETSTAT-ANP Display of network information and corresponding process number
Traceroute: The process of detecting the transmission of a packet over a network, from a native to a remote host full path
Route: Show route table


Cat browsing a file

Install MySQL
TAR-ZXVF file name. tar.gz
1. Groupadd MySQL
2.useradd-g MySQL MySQL

3. Go to MySQL folder: Initialize database: script/myusql_install_db--user =mysql

Chown-r Root. Change the owner of the current file and folder to root
Chown-r MySQL Data: Modify the owner of the data folder to MySQL
Start MySQL:
Bin/mysqld_safe--user =mysql & backstage start MySQL with MySQL user
See if the MySQL port is started
NETSTAT-ANP |more
How to access MySQL
After the CD bin
./mysql-u Root-p Root


Env |more
Showdatbase
Chgrp-r MySQL. (change MySQL for all groups of current files and folders)
If you want to start MySQL in any directory, you need to configure the environment variables (the following modifications are only for the root user):
Edit the path variable of the/root/.bash_profile file with VI:/home/mysql/bin

Use of MySQL Database
1. Enter Mysql:cd/home
Mysql-u root-p Root
show databases;
into MySQL: showtables
2 built Databases: Create DATABASE Spdbl;
3. Build table use SPDB1;
CREATE TABLE users (Usrid varchar (8), UserName varchar (8));
4. Add Data
Insert into users (' 0001 ', ' LSF ');

Desc Users: View the structure of a table
Show tables; View a table of the database

5 MySQL driver to be placed under Jre/lib/ext in the JDK home directory
5. Writing a showuser. java file
VI Showuser.java

Import java.sql.*
public class showuser{
public static void Main ([]argr) {
try{
Class.forName ("Com.mysql.jdbc.Driver");
Connetion CT =drivermanager.getconnection ("jdbc:mysql://127.0.0.1:3306/spdb?user=root&paaword=root");
Statement SM =ct.createstatement ();
ResultSet rs=sm.executequery ("SELECT * from users");
while (Rs.next ()) {
System.out.println ("Username=" +rs.getstring (1))};
}catch (Exception) {e.printstacktrace ()}

}
}

MySQL database backup and recovery:
Backup:./mysqldump-u root-proot spdb1>/home/myspdb1 Backup SPDB1 database to/HOME/MYSPDB1
Recovery: Mysql-u root-proot SPDB1</HOME/MYSPDB1

Copy folder:
Cp-r Folder 1 Folder 2
Cp-rf Folder 1 Folder 2 (if there is a folder 2,f means to overwrite directly without asking)

LN establishes a connection:
Ln-s source file A destination file B: Link file b for source file a

Grep-n "/root/abc.java/home/*" finds content with "12" and displays line numbers under all files in/root/abc.java and/home/

Find/home-name ABC find the ABC file in the/home directory

FIND/HOME-AMIN-10 files or directories accessed within 10 minutes
FIND/HOME-ATIME-10 files or directories accessed within 10 hours
Find/home cmin-10 files or directories accessed within 10 minutes
Find/homectime +10 10 hours ago changed file or directory

Search by File size
Find/home-size +10k: Find Files of size 10k in/home directory

redirect
Ls-l > A.txt The contents of the list are written to the file A.txt (overwrite write)
Ls-al >> Aa.txt The contents of the list are appended to the file Aa.txt

Shell use
Shell script files that are automatically executed after a user logs on
The. BASHRC is located in the home directory, and the script of the system before it executes/ETC/BASHRC is primarily configuration data (files that are executed after the user logs on are placed in the file)
The. Bash_profile is located in the home directory, and the script that was executed before it/etc/profile primarily configures environment variables


Alias Llh= ' ls-l/home ': ls-l/home alias for LLH

RunLevel

Transfer from http://www.cnblogs.com/sophine/archive/2012/04/26/2471187.html

Linux Command Learning

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.