Linux summary and linux learning Summary
I. file commands:
Go to the home/liuyazhuang directory
Cd/home/liuyazhuang
Ls:
Ls
Mkdir:
MkdirfamilyA
Switch the cd directory to the familyA directory:
CdfamilyA
Ls displays the content of the current directory:
Ls
Touch creates an empty file
Touchfather.txt has A father in family.
Touchmother.txt has a mother.
Touchson.txt son
Touchdaughter.txt daughter
Create a directory using mkdir
Mkdirhouse
Cd switch directory
Cdhouse
Mkdir create directory
Mkdirkitchen kitchen
Mkdirbathroom toilet
MkdirroomA
MkdirroomB
MkdirroomC
Touchsofa.txt sofa
Ls:
Ls display
Cd switch directory
CdroomB
Touch creates an empty file
Touchbed.txt
Echo "Your are the best boy."> book.txt creates a file with simple content
Catbook.txt View File Content
Cd switch directory
Cd .. back to the upper-level directory
CdroomC
Touch creates an empty file
Touchbed.txt
Echo "Your are the best girl."> book.txt
Catbook.txt
Touchdoll.txt
Cp
Cpdoll.txt/home/liuyazhuang/familyA/house/roomB
Cd switch directory
Cd ..
CdroomB
Ls:
Ls display
Cd switch directory
Cd ..
Mv mobile File
Mvsofa.txt/home/liuyazhuang/familyA/house/roomB
Cd switch directory
CdroomB
Ls:
Ls display
Rm delete file directory
Rmdoll.txt
More less page display
Morebook.txt
Wc displays the number of document lines, characters, and characters
Wcbook.txt
Find to find the specified file
Find-name book.txt
Grep searches for a specified string
Grepbest book.txt
Pwd displays the current directory
Tree display directory tree
Rmdir Delete empty directory
Rmdirbathroom
Establish a soft connection with ln-s
Ln-s/home/liuyazhuang/familyA/house/roomB/home/roomB
Ii. system management commands
Stat displays information about the specified file.
Cd/home/liuyazhuang
StatfamilyA
Who and w show online login users
Who
Whoami displays the user's identity
Hostname display Host Name
Hostname
Hostname-I display Host IP Address
Uname: displays system information
Uname-a displays all information (kernel name, host name, kernel version number, kernel version, hardware name, processor type, hardware platform type, and operating system name)
Top displays the dynamic display process of processes that consume the most resources in the current system, real-time monitoring
Ps displays Transient Process status
Ps-aux displays the status of all transient processes
Du displays the total disk space used by the specified file (directory). You can use -- help to view help.
Du
DufamilyA
Du-h familyA
Df displays the disk space usage of the file system
Df
Df-h
Free displays the usage of the current memory and swap space
Ifconfig displays network interface information
Ping to test network connectivity
Netstat displays network status information
Iii. Backup and compression commands
Gzip command
Compress all files in the familyadirectory under the/home/liuyazhuangdirectory into A. GZ file.
Cd/home/liuyazhuang
Tar-cvf/home/liuyazhuang/familyA.tar/home/liuyazhuang/familyA is first packaged, because gzip cannot directly compress the Directory
GzipfamilyA.tar Compression
Gzip-l familyA.tar.gz
Decompress familya.tar
Gzip-dv familyA.tar.gz
Gzip-v-9 familyA.tar high compression ratio
Gzip-l familyA.tar.gz
Gzip-dv familyA.tar.gz
Gizp-v-1 familyA.tar low compression ratio
Gzip-l familyA.tar.gz
Bzip2 command
Compress all the files in the familyadirectory under the/home/liuyazhuangdirectory into the. bz2 file.
Cd/home/liuyazhuang
Tar-cvf/home/liuyazhuang/familyA.tar/home/liuyazhuang/familyA
Bzip2-z familyA.tar compression requires parameter-z
Decompress liuyazhuang.tar.bz2
Bzip2-d familyA.tar.bz2
Tar command
Pack all the files in the/home/liuyazhuang/familyA Directory into/home/liuyazhuang/familyA.tar
Pack only, not compress
Tar-cvf/home/liuyazhuang/familyA.tar/home/liuyazhuang/familyA
After packaging, compress with gzip
Tar-zcvf/home/liuyazhuang/familyA.tar.gz/home/liuyazhuang/familyA
Compress With bzip2 After packaging
Tar-jcvf/home/liuyazhuang/familyA.tar.bz2/home/liuyazhuang/familyA
For special example, the file name behind "f" is retrieved, and we use" .tar "for identification on our website.
If zzip is added, .tar.gz or. tgz is used to represent the compressed tar file in gzip.
If July 2 is added, .tar.bz2 is used as the document name.
Iv. VIM Editor
VIM Editor
Create a bank.txt file in the/home/liuyazhuang/directory.
Cd/home/liuyazhuang/familyA/
Touchbank.txt
Vimbank.txt
Data command I enters the insert mode
Input content
ICBC
RMB: 10000000000
USD: 100000000000
User: familyA. father
Ctrl + C Exit the insert mode or Press ESC to switch to the command mode
: Wq press enter to save
Edit bank.txt without saving and exit
Vimbank.txt
Data command I enters the insert mode
Enter whatever content
Ctrl + C Exit the insert mode or Press ESC
: Q! Press enter to force exit
Edit bank.txt and display the row number
Vimbank.txt
: Setnumber press ENTER
: Q: Press enter to exit normally.
5. users and groups
Add an account
Useradd-m ltw parameter-m is used to set the system to automatically create the user root directory when adding an account
Adduser
Modify the logon name of an ltw account
Usermod-l litingwei ltw
Modify the logon directory of the litingwei account (Note: You must manually create the litingwei directory before modification)
Usermod-d/home/litingwei
Lock user litingwei account password
The account is unavailable after usermod-L litingwei is locked.
Unlock user litingwei account and password
Usermod-U litingwei
Add a group
Groupaddsuperman
Modify a superman Group
Groupmod-g 355 superman
Delete a superman Group
Groupdelsuperman
Modify the root password (the root password has not been set. You can use it only after setting the password)
Passwdroot
Root, litingwei account Switch
Su-root
Or sudo-I to switch to root
Delete the litingwei account
Userdel-r litingwei (-r is deleted together with the user directory)
Vi. File Permissions
Show the file/home/liuyazhuang/familyA/bank.txt Permissions
Cd/home/liuyazhuang/familyA/
Ls-l
Switch to litingwei user
Sulitingwei
Use litingweiaccount accounts to read and write bank.txt
Catbank.txt
Vimbank.txt at this time, litingwei does not have the permission to modify the file
Switch back to liuyazhuang
Suliuyazhuang
Modify bank.txt to allow other users to read and write
Chmodo + w bank.txt
Switch back to litingwei
Sulitingwei
Modify bank.txt
Vimbank.txt
7. Build a java environment
Step 1 install jdk
Switch su-root to root user
Sudo-I directly switches to root without a password
1. Enter the usr directory
Cd/usr
2. Create a java installation directory under the usr directory
Mkdir java
3. Copy jdk-6u24-linux-i586.bin to the java directory
Cp/home/liuyazhuang/Desktop/jdk-6u24-linux-i586.bin/usr/java/
4. Install jdk
Cd/usr/java
/Jdk-6u24-linux-i586.bin
5. After the installation is complete, create a link for him to save the directory Length
Ln-s/usr/java/jdk1.6.0 _ 24 // usr/jdk
6. Edit the configuration file
Vim/etc/profile
Add the following content:
JAVA_HOME =/usr/jdk
CLASSPATH = $ JAVA_HOME/lib/
PATH = $ PATH: $ JAVA_HOME/bin
Export PATH JAVA_HOME CLASSPATH
8. Restart the machine or source/etc/profile
Sudo shutdown-r now
9. view the installation status
Java-version
Java version "1.6.0 _ 24"
Java (TM) SE Runtime Environment (build1.6.0 _ 24-b07)
Java HotSpot (TM) Client VM (build 19.1-b02, mixed mode, sharing)
Step 2 install tomcat
Tar-zxvf apache-tomcat-6.0.29.tar.gz-C/opt (unzip to/opt)
Ln-s/opt/apache-tomcat-6.0.29 // opt/tomcat (create a link file)
Start tomcat
Cd/opt/tomcat/bin/
./Startup. sh (Note: points represent the current directory)
If it cannot be started, try
-I switch to the root user and restart
./Startup. sh
Test http: // 127.0.0.1: 8080/
Step 3 install eclipse
Tar-zxvf eclipse-SDK-4.2-linux-gtk.tar.gz-C/opt (decompress to the/usr/local directory and generate the/usr/local/eclipse directory)
Cd/opt/eclipse/
./Eclipse (Note: The point indicates the current directory)
8. ssh remote Logon
1. install openssh-server
Sudo dpkg-I openssh-client_1 % 3a5. 5p1-4ubuntu6_i386.deb
Sudo dpkg-I openssh-server_1 % 3a5. 5p1-4ubuntu6_i386.deb
If the network connection is connected, you can install sudoapt-get install openssh-server.
2. Set the ip address
Sudo ifconfig eth0 192.168.1.222 netmask 255.255.255.0
3. Start ssh-server.
$/Etc/init. d/ssh restart
Service ssh restart
4. confirm that the ssh-server is working properly.
$ Netstat-tlp
Tcp6 0 0 *: ssh *: * LISTEN-
The above output indicates that the ssh-server is already running.
5. log on to the server through ssh on the client. Assume that the IP address of the server is 192.168.0.103, And the logon username is hyx.
$ Ssh-l hyx 192.168.0.103
Next, you will be prompted to enter the password, and then you will be able to successfully log on to the server.
9. SSH Trust
1. Generate a key file on the first host (the hidden directory of. ssh is generated under the user root directory, and two files are generated under some Directories)
Id_dsa ------------ Private Key File
Id_dsa.pub ------------ Public Key File
Command:
Ssh-keygen-d
2. Copy id_dsa.pub with the file name authorized_keys2.
Change the authorized_keys2 attribute to 600, that is, the file owner has the read and write permissions, and the group users and other users are prohibited from reading and writing.
Command:
Cp id_dsa.pub authorized_keys2
Chmod 600 authorized_keys2.
3. Generate a key file on the second host
See the previous two steps
4. Copy the id_dsa.pub public key file under the/home/work/. ssh directory on server_1
Under the/home/work/. ssh directory of server_2 (Note: Do not overwrite id_dsa.pub of server_2, and change the name when copying it)
Command:
Scp id_dsa.pubwork @ server_2:. ssh/server_1.pub
5. view the. ssh directory files on server_2:
Authorized_keys2
Id_dsa
Id_dsa.pub
Server_1.pub
6. Put server_1.pub content in authorized_keys2. Be sure to use the append operation ">" "> ")
Command:
Cat server_1.pub> authorized_keys2
5. Test
Ssh work @ server_2
Level 1 (password-based security verification ),
You can log on to the remote host as long as you know your account and password,
All transmitted data is encrypted.
However, this authentication method cannot ensure that the server you are connecting to is the server you want to connect.
Other servers may pretend to be real servers, that is, being attacked by man-in-the-middle (mitm) attacks.
Level 2 (key-based security verification) relies on keys,
That is, you must create a pair of keys for yourself and put the public keys on the server to be accessed.
If you want to connect to the SSH server, the client software will send a request to the server, requesting your key for security verification.
After receiving the request, the server first searches for your public key in the user root directory of the server,
Then compare it with the public key you sent. If the two keys are the same, the server uses the public key to encrypt the challenge and send it to the client software.
After receiving the question, the client software can use your private key to decrypt it and then send it to the server.
Compared with the first level, the second level does not need to transmit user passwords over the network.
In addition, the second level not only encrypts all transmitted data, but also the "intermediary" attack method is impossible (because it does not have your private key ). However, the entire logon process may be slower.
LINUX learning experiences
First, tell you not to be afraid. You can install it as prompted. Then, read the following:
Linux installation in Windows
HQY published on 18:25:00
If you want to use both Windows and Linux systems on the same computer, you must first learn to install Linux on a computer with Windows systems installed.
For Windows/Linux systems with multiple operating systems, the installation sequence is to install Windows first, and then Linux. Next we will introduce how to install RedHat Linux 9.0 on a single hard disk that has been installed on Windows.
Preparations before Linux Installation
1. Collect hardware information in Windows
Before installing Linux, you need to use the Windows system to learn basic information about computer hardware, such as the memory size, sound card, display, mouse, and graphics card model.
2. Set the boot system from the CD
Linux supports several installation methods, but it is most convenient and fast to directly start the installation with a CD boot. If you want the machine to start with a CD, you need to modify the BIOS settings, change the CD-ROM to the first place on the machine order.
3. Linux partition
Linux partition Representation
Partitioning separates disk drives into independent areas. Each area is like a separate disk drive. in DOS/Windows, disk partitions can be divided into C, D, and E disks. However, in Linux, disks are managed and used as block device files, which start with/dev (device abbreviation.
For example, in Linux, "/dev/hda1" is used to represent the C drive in Windows.
Among them, hd indicates the IDE Hard Disk (sd for SCSI hard disk); hda indicates the first IDE Hard Disk (hdb for the second);/dev/hda1 indicates the primary partition, and the logical partition starts from 5, for example: /dev/hda5,/dev/hda6,/dev/hda7, etc.
Prepare partitions for Linux
Linux partitions are different from Windows partitions and cannot be shared. Therefore, you need to create an idle partition for Linux, preferably the last partition. 1. Use the Partition Magic (Partition Magic) software in Windows to free up space on disk D to create a new Partition edisk (or use an existing idle edisk). The file type is currently set to FAT32, for Linux partition creation later, RedHat 9.0 requires about 4 ~ 5 GB space.
4. Linux File System
File systems vary with operating systems. The Windows File System is FAT16, FAT32, and NTFS. Linux file systems can be divided into ext2, ext3, swap, and vfat. Ext2 supports a file name of up to 255 characters. ext3 is based on ext2. It mainly reduces the time it takes to restore the file system after the system crashes. RedHat 9.0 defaults to ext3; swap zone swap is used to support virtual memory; Windows FAT partition is displayed as vfat file type in Linux.
1. boot with the first installation disc of RedHat 9.0. The installation menu will appear after the system is started.
The installation Menu provides a graphical and text Installation Method for the user to choose from. Press enter to select the graphical mode for installation. Before entering the installation mode of the graphic screen, RedHat 9.0 is more than the previous version, that is, it prompts to check the installation disc media, or you can press the "Skip" button to Skip the detection.
2. Then the installer automatically detects the hardware, including the video card (Display Card), display, and mouse configuration, and then enters the Installation Wizard of the graphic screen. In the "language selection" screen, select "simplified Chinese", so that the text on the subsequent installation interface will be changed to Chinese. On the keyboard configuration screen, use the default American English keyboard. Select... the remaining full text>
Who has learned from Linux?
I am studying linux every day and have some experiences to share with you.
First of all, it is useless to learn about linux simply by reading books. Because the linux kernel and software are updated too quickly, the software configuration method described in the book is often not suitable (mostly version conflicts or incompatible ), the hardware and software configurations of your machine are different from those of the machine used in the book, which may also cause software installation failure. In comparison, many articles on the Internet are quite new, and they are much better than books in solving practical problems. However, the book has the advantages of the book, the book is very comprehensive, the configuration of a command or software has been analyzed a lot, and most articles on the Internet are targeted. Therefore, it is necessary to combine the book with the network and learn the principles through the book. If the actual problem cannot be solved, Baidu or google more.
In addition, although everyone prefers the beautiful mm, when learning linux, they still need to contact the "man": when P encounters a problem, in addition to online queries, we need to use the man command in linux to find help.
The last thing to say is that although apt-get or yum (depressing) is very convenient, it is best to download the source code package to install the software, I can't install apt-get, because now I want to learn more complex things in linux, so I will take a shortcut when I need to use it in the future. In addition, try multiple parameters as much as possible during configure and set your own -- prefix path. Also, do not worry about installing software to mess up the system. If the system crashes, reload the system once. If you install the system several times, you will get started with linux. (I installed the system four or five times a day.) try multiple linux versions as much as possible when installing the system. There are many releases of linux. They are different in many places, so I don't know what else I used. For example, I used to use red hat to start the inittab settings. When I used ubuntu, I found that inittab was gone, instead, events/is replaced, and the startup level is not rh. 3 is the Terminal 5 is the graph, and the ubuntu 2-5 is the same, there are many differences (I will briefly introduce the differences between rh AND ubuntu IN THE NEXT blog ).
In short, I think it is more convenient to use windows for entertainment, but if you want to use a computer to work (programming, server, etc.), you should use linux. To learn linux well, one is to read more books and practice, and the other is to have a solid foundation of computer knowledge. If the foundation is not solid, take this opportunity to make up for it.
Reference: www.linuxdiyf.com/bbs/thread-46274-1-1.html