Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Basic Tutorial: Linux novice should know 26 commands     - SSH keys using login and password to log prohibited practice (Linux)

- Linux input and output redirection (Linux)

- How to deploy Python Web application: Heroku deployment process complete records (Server)

- How to use the internal network IP forwarding to connect to the Internet on Linux (Linux)

- 24 Docker recommendations (Linux)

- MySQL function: group_concat () function (Database)

- Explore Android SQLite3 multithreading (Programming)

- Android Unzip the ZIP / GZIP data (based on the InflaterInputStream implementation) (Programming)

- About Linux backdoor (Linux)

- Configure the ASM process on Red Hat Linux 6.5 (Database)

- ORA-00911 invalid character error Solution (Database)

- Network traffic monitoring ntopng (Linux)

- Java developers question (Programming)

- for (int a: i) the use of the Java programming (Programming)

- Linux kernel TCP / IP parameters analysis and tuning (Linux)

- IPTABLES configuration steps under Linux (Linux)

- Apache site default home page settings (Server)

- Protobuf compiled and used on the Ubuntu 14.04 (Programming)

- Use value type build better applications Swift (Programming)

- JQuery implements the same content merge cells (Programming)

 
         
  Basic Tutorial: Linux novice should know 26 commands
     
  Add Date : 2017-01-08      
         
         
         
  When you enter the world of Linux, download, install a Linux distribution, the Linux desktop experience and installed something you love and need software after Linux should get to know the real charm: the command line. Each Linux command is actually a program, with the help of these commands, we can do a lot of things. The following will tell you about a few commonly used commands.

How to get help?

Problems encountered in Linux, the most important thing is to seek help themselves, here are three methods to seek help.

man

Linux is a man with the help of the manual, that manual. Since most programs will bring their own manual, so you can get help through the man command. After the execution, the man page page press q to quit.

Get help for ls

$ Man ls
See how many (different aspects) of the same name has manual

$ Man -f ls
ls (1) - list directory contents
ls (1p) - list directory contents
See specific manual

$ Man 1p ls
 
info

The difference is that the man can jump like browsing web pages in each node.

Start browsing from Docs

$ Info
Get help on a specific program

$ Info program
 
help

In addition to the above two methods, there is a simple method to use, that is --help parameters, the general procedure will have this parameter, the output will be the simplest useful introduction.

$ Man --help ### for help of man
Get info $ info --help ### help
$ Ls --help ### to get help for ls
 
How simple?

Terminal (Terminal), the many operating skills, here are a few simple.

cursor

up (arrow keys) Enter the execution history can be retrieved quickly execute commands
down (down arrow keys) with up to select execution history
Home to move the cursor to the beginning of the line
End Move the cursor to the end of the Bank
PgUp Page Up
PaDN Down
ctrl + c to terminate the current program
 
Tab completion

Tab completion is a very useful function that can be used to automatically complete the command or file name, saving time and accurate.

Even without entering the state press Tab twice to list all available commands
Has entered part of the command name or file name, press the Tab automatic completion, you will surely be used more like a.
Common Commands

The following commands are arranged in accordance with the usual frequency of use.

cd

cd command is to open a path, that is, open a folder, and jump to the premises.

$ Cd path ### path is the path you want to open.
Which path has the absolute and relative paths of the points, to emphasize the absolute path from /, has been host to the path. Relative paths are relative to the current path, it is assumed that the current home directory etc folder (absolute path would be / home / username / etc), if you enter the direct cd etc folder, but if it is cd / etc / is entered system etc, pondering what can be understood. Also in Linux, the representative of the current directory, .. on behalf of parent directory, so you can return to the parent directory cd ...

ls

ls That list, list the files.

$ Ls ### list only visible files in the current directory
Current directory, see file details $ ls -l ### listed
$ Ls -hl ### lists detailed information in a readable size displays the file size
For more information $ ls -al ### lists all files (including hidden)
Note: Linux to the beginning of the file or folder are hidden files or hidden folders.

pwd

pwd used to return the name of the current working directory, an absolute path name.

$ Pwd
/ Home
 
mkdir

mkdir to create a new folder.

$ Mkdir folder
$ Mkdir -p folder / subfolder ### -p parameter is ignored when the parent directory exists, if the presence is established, use this parameter to establish a multi-level folder
 
rm

rm ie remove, delete files.

$ Rm filename ### Delete filename
$ Rm -i filename ### before deleting the filename prompt, prompt if more than one file every time
Under $ rm -rf folder / subfolder / ### subfolder recursively delete all files and folders, including the subfolder itself
$ Rm -d folder ### delete empty folders
 
cp

cp That copy, copy files.

$ Cp source dest ### to copy source to dest
$ Cp folder / * dest ### to all the files under the folder (without subfolders in the folder) is copied to dest
$ Cp -r folder dest ### folder and all the files (including sub-folders all files) copied to dest
 
mv

mv That move, move files.

$ Mv source folder ### will move to the next source folder, was completed folder / source
$ Mv -i source folder ### while moving, if the file already exists you are prompted whether to overwrite ** **
$ Mv source dest ### at dest directory is not the premise, to rename the source dest
 
cat

cat used to output the file contents to the Terminal.

Content $ cat /etc/locale.gen ### of output locale.gen
Output $ cat -n /etc/locale.gen ### locale.gen and display line numbers
 
more

and more similar to cat, you can view the contents of the file, the difference is that when a document is too long, cat only show the last full contents of the screen, in front of the content is not visible. This time can be used more progressive display.

$ More /etc/locale.gen
$ More + 100 / etc / locale.gen ### from 100 lines began to show
 
less

less and more similar, but less support to scroll content, and more only support progressive display.

$ Less /etc/locale.gen
$ Less + 100 / etc / locale.gen

nano

nano is a simple and practical text editor, simple to use.

$ Nano filename ### edit filename file, if the file does not exist, a new open file, save if the exit, the file is created
After editing, ctrl + X prompted to save, press y OK to save.

Note: Available ctrl + G to get help during use.

reboot

reboot command to restart.

# Reboot ### '$' and '#' difference is that the '$' ordinary users can perform
### And '#' before execution for the root user, or ordinary users to use 'sudo'
 
poweroff

poweroff for the shutdown command.

# Poweroff ### immediately shut down
 

ping

ping is mainly used to test network connectivity by sending a packet to the target machine to test whether the two hosts communicating, and delay the case.

$ Ping locez.com ### ping the domain name, if DNS is not set up, you may not ping
$ Ping linux.cn
PING linux.cn (211.157.2.94) 56 (84) bytes of data.
64 bytes from211.157.2.94.static.in-addr.arpa (211.157.2.94): icmp_seq = 1 ttl = 53 time = 41.5 ms
64 bytes from211.157.2.94.static.in-addr.arpa (211.157.2.94): icmp_seq = 2 ttl = 53 time = 40.4 ms
64 bytes from211.157.2.94.static.in-addr.arpa (211.157.2.94): icmp_seq = 3 ttl = 53 time = 41.9 ms
^ C
--- Linux.cn ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min / avg / max / mdev = 40.406 / 41.287 / 41.931 / 0.644 ms
$ Ping 211.157.2.94 ### through the IP address ping, if you can not ping may be network connectivity issues
 
grep

grep is mainly used for matching item is returned, it supports regular expressions.

$ Grep PATTERN filename ### returns all rows containing PATTERN
$ Grep zh_CN /etc/locale.gen ### returns all rows containing zh_CN
 
mount

mount is used to mount a file system, you need root user to perform. A disk can be divided into several partitions, you can create a file system on top of the partition, and a mount point is to provide access to the entrance, a partition file system is mounted to a directory, the directory is called the mount point and you can access the content through the file system mount point.

For example, a hard disk expressed in Linux as / dev / sda then the partition above it should be expressed as / dev / sda1, / dev / sda2.

# Mount ### outputs the current system mount information
# Mount / dev / sda1 / mnt ### will sda1 on / mnt in
# Cd / mnt ### directly through the / mnt to access the content
# Mount -o remount, rw / mnt ### remounted sda1 to / mnt and set to read-write
# Mount -a ### configured to mount the file system fstab file
 
umount

umount and moung the contrary, it is to uninstall a mount point, that the abolition of the entrance.

# Umount / mnt ### uninstall / mnt mount point of the file system
# Umount -a ### unmount all mounted file systems
 
tar

tar is mainly used to create the archive file, and unzip the archive, which itself is no compression, but you can call gzip, bzip2 compressed.
Parameter explanation:

-c to create an archive
-x-extracting archive
-v display processing procedure
-f target file, the target file must be subsequently followed
-j call bzip2 to decompress
-z call gzip to decompress
-t lists the files in the archive
$ Tar -cvf filename.tar. ### The current directory of all filing, but does not compress, watch behind a '.', It can not be omitted, on behalf of the meaning of the current directory
$ Tar -xvf filename.tar ### unzip filename.tar to the current folder
$ Tar -cvjf filename.tar.bz2. ### Compressed with bzip2
$ Tar -xvjf filename.tar.bz2 ### unzip filename.tar.bz2 to the current folder
$ Tar -cvzf filename.tar.gz ### compressed with gzip
$ Tar -xvzf filename.tar.gz ### unzip filename.tar.gz to the current folder
$ Tar -tf filename ### to see only the filename files in the archive without extracting
 
ln

ln primarily used to create a link in two files, the link is divided into Hard Links (hard link) and Symbolic Links (symbolic link or soft link), which defaults to create a hard link, use the -s parameter to specify create a soft link.

Hard link is to increase the number of links to a file, as long as the number of links to the file is not 0, the file will not be physically removed, so delete more than one file with hard links, you must remove all of its hard links only be deleted.
Simple soft link is created for the file something like a shortcut, you can access files, modify the file through the link, but will not increase the number of links to the file, delete a soft link does not delete the source files, even if the source files are deleted, soft links also exist when re-creating the source file of the same name, the soft link points to the newly created file.
Hard link can only link two files can not link directories, soft links can link directory, so soft link is very flexible.
$ Ln source dest ### to create a hard link named dest to source
$ Ln -s source dest ### to create a soft link named dest to source
 
chown

chown for changing a file's owner and the group is located.

# Chown user filename ### for the user to change the filename of the owner
# Chown user: group filename ### to change the filename of the owner of user, group, group
# Chown -R root folder ### to change the owner of folders and subfolders folder is root
 
chmod

chmod never changes the permissions of a file, there are read, write, execute, three permission, which the owner, the user group, the other three each, thus ls -l can see the following information

-rwxr - r - 1 locez users 154Aug3018: 09 filename
Where r = read, w = write, x = execute

# Chmod + x filename ### add execute permissions for user, group, others
# Chmod -x filename ### canceled execute permissions user, group, others of
# Chmod + w filename ### add write permissions for the user
# Chmod ugo = rwx filename ### set user, group, others have read, write, execute permissions
# Chmod ug = rw filename ### set user, group add read, write permissions
# Chmod ugo = --- filename ### cancel all privileges
 
useradd

useradd is used to add a normal user.

# Useradd -m -g users -G audio -s / usr / bin / bash newuser
### -m Create home directories, main group belongs -g, -G specified additional user group which, -s set the default shell, newuser new username
 
passwd

passwd is used to change the user password.

$ Passwd ### without parameters, change the current user password
User password # passwd newuser ### to change the above-mentioned new newuser
 
whereis

whereis for finding documents, manuals, etc.

$ Whereis bash
bash: / usr / bin / bash /etc/bash.bashrc /etc/bash.bash_logout /usr/share/man/man1/bash.1.gz/usr/share/info/bash.info.gz
$ Whereis -b bash ### only to find binary
bash: / usr / bin / bash /etc/bash.bashrc /etc/bash.bash_logout
$ Whereis -m bash ### only to find manual
bash: /usr/share/man/man1/bash.1.gz/usr/share/info/bash.info.gz
 
find

find also used to find files, but more powerful, support for regular, and search results can be passed to other commands.

$ Find.-Name PATTERN ### PATTERN find qualified file from the current directory
$ Find / home -name PATTERN -exec ls -l {} \; # Find / home file PATTERN all matching files and output by the ls details
 
wget

wget is a download tool, simple and powerful.

$ Wget -O newname.md https://github.com/LCTT/TranslateProject/blob/master/README.md ### download README file and rename it to newname.md
$ Wget -c url ### url download and open HTTP
     
         
         
         
  More:      
 
- The security administrator network analysis tools SATAN Introduction under Linux (Linux)
- Use OpenWrt build WDS wireless network extension on V2 WHR-G300N (Linux)
- Use ISO document production OpenStack used CoreOS mirror (Linux)
- MongoDB fragmentation (Cluster) (Database)
- Nginx log cutting and MySQL script regular backup script (Server)
- Linux Quick Install MongoDB (Database)
- Oracle Database High-Risk Vulnerability Warning (Database)
- Distributed File System FastDFS deployment (Server)
- Github Getting Started Basic Course (Linux)
- Oracle how to assess the true concurrent session (Database)
- To install and use Docker under linux (Server)
- Open MySQL slow query log (Database)
- Manually compile Hadoop 2.6.0 under Ubuntu 14.04 (Server)
- RPM package management under Linux (Linux)
- Linux learning portal: CentOS 6.4 system kernel upgrade (Linux)
- Linux automatic installation and implementation (Linux)
- To generate a certificate using OpenSSL under Linux (Server)
- Oriented C ++ test-driven development (Programming)
- Nginx Load Balancing (standby) + Keepalived (Server)
- MySQL loose index scan (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.