One, the process of command line operation
1. Input command (can use various channels to send commands), enter the end
1. The command is interpreted and executed by the interpreter
2. Display the results in a way that the product needs
Second, command prompt
[Email protected]:~$
Changru: Currently logged in User name
Changru-virtualbox: Current host name
~: Indicates the current position
$ after: Used to receive commands
The $ in prompt indicates that the current logged on user is a normal user
The # in the prompt indicates that the current logged on user is the root user
Iii. three elements of the order
Command option Parameters
Three elements separated by a space
Command: Represents the action to be performed do
Options: Indicates how you want to perform the operation.
Option to-start
Parameters: The object that represents the execution of the action who
Note: If an option or parameter is not provided, the default value is treated as
Iv. Common Commands--auxiliary class commands
1.pwd self-positioning
Usage examples:
$pwd
/home/changru
Prints the absolute path of the current directory
Absolute path: directory path structure with/start
Relative path: A directory path structure that is not/begins with
2. man help manual Query command
form of Use:
Mans command
Usage examples:
$man pwd
3.Claer Clear Screen command
4.su Select/Switch User
5.sudo (change body)
When permissions are insufficient, use sudo temporarily to become the root user
form of Use:
sudo command [option] [ARG]
Note: Only users who are inside the sudo user group can use the sudo command.
V. Common commands--file directory class commands
1.ls (list) lists file information for the specified or default directory
form of Use:
ls [options] [directory name]
Instance:
$ls
$ls-A
$ls/home/changru/Desktop
$ls./Desktop. Represents itself. Represents the previous level of the directory
$ls-L
D rwx R-x R-x 3 Changru changru 4096 July 10:45 Desktop
Common options:
-A: Displays all files, including. and. )
- L: Show detailed information for the listed files
- H: Display file information in a more readable manner (typically used in conjunction with-L)
- D: Displays information about the directory itself rather than directory content (typically used with-l)
Bin Home Sbin Boot
2.CD directory jump
form of Use:
CD Destination directory path
Common usage Scenarios:
Quick Home Directory: CD or CD ~
Skip to the top level directory: CD. (equivalent to a previous page)
Quick Jump between catalogs: cd directory path
Note: The CD command works with the LS command to complete the view of the entire directory structure
3.mkdir Create a directory
form of Use:
mkdir path to the directory to be created
Instance:
$mkdir ~/linux (absolute path) where ~ represents/home, so is the absolute path
$ls
Common scenarios:
To create a directory under the specified directory: mkdir path
Recursively creating directories: Mkdir-p Path
4.rmdir Delete directory (directory must be empty)
5. file to view the files type specified
In Unix-like operating systems, the file extension only acts as a hint and does not affect the file type.
Use form: File file name
6.Touch
Use form: Touch file path
Instance:
$touch hello.c
If the specified file does not exist, an empty file with the same name is created.
7.RM Deletes the specified file or directory
form of Use:
Delete normal file: RM file path
Delete directory file: Rm-rf directory path (-RF can be forced to delete as long as permissions are sufficient)
Practice One:
1) in the home directory of the currently logged in user, create a project catalog Sq-qq
2) in the SQ-QQ directory, create the directory bin, Src, lib, include, test
3) Create file in Sq-qq directory readme, license, Makefile
4) Create files in src directory linklist.c, linklist.h, MAIN.C, Makefile
8.CP Copy the specified file or directory to the specified directory
form of Use:
CP Source Dest
Common usage scenarios
1) file-to-directory replication presupposes that the destination directory must exist
CP/ETC/PASSWD ~/linux/
Destination Directory exists: Copy to specified directory
The destination directory does not exist: The change is 2)
2) file to file copy file to specified directory and rename
CP/ETC/PASSWD ~/test
Destination directory does not exist: copy and rename
Destination Directory exists: copy content and replace
3) directory to directory Note: The copy directory needs to be added with the-r option
Cp-r ~/sq-qq/~/linux/(-R can copy files and folders)
Destination Directory exists: Copy the directory to the current directory
Destination directory does not exist: Copy directory to top level of destination directory and rename
Exercise two:
1) Create a Weibo directory in the home directory of the currently logged-in user
2) Create the sina_weibo.h in the Weibo directory
3) Copy the Weibo directory to the Include directory under the SQ-QQ directory
9.MV move files or directories to the specified directory
Use form: MV Source dest
Common usage Scenarios:
A) file to directory
MV ~/PASSWD ~/linux/
Destination directory file exists: Simple file Move operation
Destination directory file does not exist: change to case B)
B) file to file
MV ~/PASSWD ~/linux/hahaha
Destination file does not exist: Move and rename
Destination file exists: Move and overwrite
Note: The file moves in place to achieve the effect of renaming
MV Hello.c MAIN.C
C) directory to Directory
MV ~/sq-qq/~/linux/
Destination directory file exists: Move directory data to the specified directory
Destination directory file does not exist: Move directory to top level of destination directory and rename
Vi. Common Commands--File content class operations
1.cat
2.head
3.tail
4.more displays multiple rows of data in a paginated manner
5.less displays multiple rows of data in a paginated manner
Vii. Common Commands-user and group management
1.PASSWD Modify the password for the specified user
form of use: passwd username
Common usage Scenarios:
By default, the Ubuntu system does not activate the root user and needs to use passwd to modify the root user password.
sudo passwd root
Added:/etc/passwd files in the system
2.adduser/useradd
Use form: sudo adduser user name
Common usage Scenarios:
A) Create A new User: sudo adduser user name
B) Add an existing user to the existing group: sudo adduser username Group name
3.deluser/userdel
Use form: sudo deluser user name
Common usage scenarios: sudo deluser-remove-home
Viii. Common Commands--permission-related
The whole Linux system's permission system is mainly for the file owner, the file belongs to the group, other users of the read, write, execute permissions constitute
Ls-l can view permissions information for normal files
Ls-ld can view permissions information for the directory file itself
D rwx R-x R-x 3 changru changru 4096 July 21 10:45 Desktop
File Owner Permissions file belongs to group permissions Other user rights
READ: Whether it is a normal file or a directory file, read permissions affect the information on the file view
Write: For ordinary files, write permissions affect the content of the file, and for directory files, write permissions affect new and deleted files for that directory.
Execute: For normal files, execute permissions affect whether the file can be loaded into memory run, and for directory files, execute permissions affect whether the directory can be CD (accessed).
1.chmod Modify the permissions of a file without changing the file affiliation
form of use: chmod new permission file name
Permissions can be represented by using three octal numbers
chmod 644 Weixin.h
4 2 1
1 1 1 7
1 0 1 5
1 1 0 6
1 0 0 4
R W X
2.chown changing the owner of a file and the owning person
Use form: sudo chown [user][:group] File name
Common usage Scenarios:
Change only file owner: sudo chown user name file name
Change only the group that the file belongs to: sudo chown: Group name File name
Change both the file owner and the group to which the file belongs:
sudo chown user name: Group name File name
Ix. Loading and unloading software
1. Install the graphical application
A) using Ubuntu's own software center
b) Download the binary installation package for Ubuntu
2. Installation of the command line related tools
A) update of apt-get Update software name
b) apt-get install software name
c) apt-get remove software name removal
d) Apt-get source software name
Practice:
$sudo apt-get Update
$sudo apt-get Install SL (Small train)
X. Compression and archiving
1.zip/unzip
A) Compress the specified file: Zip test.zip hello.c main.c
B) Unzip the file: Unzip dest.zip-d extract Directory
2.bzip2/bunzip2
3.gzip/gunzip
4.tar Archive and Compress (package)
- C Create an archive
- x Solution Archive
- v Show Archive/Unpack process information
- F filename Specifies the input/output file name
-j compressing/extracting files using bzip2
- z compress/unzip files using gzip
- C Directory decompression to the specified directory
A) Create an archive and specify the output file:
TAR-CVF output file name to be compressed file list F must be followed by file name
B) archive from the specified archive file
TAR-XVF Pending Archive file
C) simultaneous compression or decompression using BZIP2 to complete archiving
TAR-CJVF output_filename.tar.bz2 List of compressed files to archive (can include directories)
TAR-XJVF input_filename.tar.bz2
D) simultaneous compression or decompression using GZIP to complete archiving
TAR-CZVF output_filename.tar.gz2 file to archive list of compressed files (can contain directories) new file name
TAR-XZVF INPUT_FILENAME.TAR.GZ2 < Extract to current directory >
The file name to be unzipped
Xi. Mount Mount Umount
Supplemental: Ifconfig NIC Configuration
Evening Practice:
1. Install tree, vim from the command line
2. Download the Atom Text Editor installation package Atom*.deb
3. Be familiar with the commands you have learned
4. Try to install using SL, Cowsay fun Software
Getting Started with Linux basics