Linux file system architecture and commands

Source: Internet
Author: User
Tags save file zip folder ftp client

1.linux File System Architecture
/root directory root
|--mnt/
| |--sdcard/mount point
| |--usb0
| |--cdrom
|--home
| |--soft01 <-User home Directory

2. Absolute path:/start path
Absolute path is the location starting from the directory
Relative path: Not the/start path
The equivalent path is relative to the current directory's path location

Cd/etc
CD Desktop
Cd/home/soft01/desktop
Cd.. Change the current working directory to: (Parent directory)
CD Change Directory
The CD command without parameters is the command to go back home

3. Commands: Command [-options] [parameters]
1) LS column directory command
LS Column current directory
ls/Reagan directory contents
Ls/home the contents of a column/home folder
Ls-l long, displayed in long format

2) CD Back to Home
CD/Change the current directory to the root directory/
Cd/home changing the current directory to/home
CD/ETC changing the current directory to/etc

3) PWD Print current working directory

4) mkdir Create folder
mkdir Demo folder to create demo in the current folder

5) MV Change or move files and folders (move)
MV Source Target
Source: Must exist on the hard disk (file, folder), otherwise there will be errors
Target: If not present, rename, rename file, folder to target file, folder
If the destination is a folder that exists, move the source files and folders to this destination folder

6) RM Delete files, folders
RM file Name
Rm-rf folder
-rf selecting the R and F options
-R recursively Delete all subfolders
-F Force Delete all files in folder

7) Touch Create an empty folder
Change the time of the file

8) CP copy files, folders
Copying files
CP Source Target
Source: must exist, otherwise there is an error
Target: Not present, copy source file to target file, rename copy
exists, is a file that overwrites the target file
exists, is a folder that copies the destination file to a folder with the same name as the source file
Copy Folder
Cp-r Source Target
-r option: recursively copy subfolders
Source: must exist, otherwise there is an error
Target: Not present, copy the source folder name to the destination folder, the folder contents are the same
Destination is a folder that exists and copies the source files to the destination folder

9) Cat View text file content, only view text files!

More split screen display
More filenames, split-screen display of files
Using the Pipe link command
Link the output of one command to another command as input
Cat Abc.txt | More
ls/etc | More

One) grep is often used as a conduit to connect
Select filters for results, leaving rows that meet the criteria
ls/etc | grep PA Filters The results of the first command, preserving the results of the PA sequence

chmod Rights Management
Ls-l
User U
Group G
Others o
R W X
chmod u+r,u_e,u-x,g-r,g-w Abc.txt
Using numbers
Rwx
---000 0
--x 001 1
-w-010 2
-WX 011 3
r--100 4
R-x 101 5
RW-110 6
RWX 111 7
rw-------
110 000 000
6 0 0
chmod abc.txt
Folder X is authorized: can enter

4. Advanced Commands
1) vi character interface of the full screen visual editor, is the classic Unix, Linux editor, widely used. Editing text files at the command line interface
VI [filename] opens the edited file. If there is a file that does not exist, create a new file, if there is no file name,
When you save, give the file name
Status of VI
Command status-I o A-insert (edit) status
<-[esc]-
I:insert commonly used to interpolate characters at the position after the cursor
O:open inserting characters at the end of a file
A:append append characters after the cursor
VI is command state when open
Common commands:
[ESC]: Return to command State
: w [filename] write command, save file, if given filename, save as "Sava as",
You can use absolute or equivalent paths
: w! [File name] Force save, if the file is the current user's read-only file, you can use this feature to save
: Q quit the command, leave VI software, if the file content has been changed, has not been saved, can not quit
: q! Force quit, do not save the exit, is to discard the modification of the file
: Wq Save and exit
: wq!
DD Delete Delete cursor when moving forward
DW Delete Word removes the light position word
DND N is the number that deletes n rows
H J k L Move cursor position
: Help Manual, exit: Q
? XXX forward Search xxx
/xxx Backward Search XXX
N Next continue searching for the next
^n continue searching for the previous
Command state: Any keystroke is a command
Edit Status: Any keyboard strokes are text input
Hidden files: Files and folders that begin with.
Ls-a: Viewing hidden files
~ Represents user Home Directory
Example: cp/etc/passwd ~ Copy files to the user home directory

2) telnet and SSH login commands
Telnet early command, no encryption, clear text transmission, unsafe, can be intercepted by interception
SSH instead of Telnet, is encrypted transmission
Client: One end of a remote connection initiated
Server: Computer to which the servers are connected
To start the running Server software telnetd sshd
Client (telnet) Server (telnetd)
telnet IP [port]-Connection
<-user-
USER:SOFT01-----> Authentication Server users
pwd:soft01
(is the user of the server)
<-Success-
PWD----->
< Directory of-----servers
LS----->
<-----Server directory list
VI File-----> Edit Server files
...
Exit----->
<--bye--

 client  server (IP)
 ssh [ Email protected]   -----;
    <-Certificate-
   yes    -----
    <-passwd-
  pwd   ---->  Certification Successful
 ls
 vi
  ....
      
    ifconfig Query The network configuration of the current Linux computer
 if = interface = Network card
 /sbin/ifconfig
 addr:192.168.160.178

3) Remote file transfer ftp SFTP
   Client (Local)    server (IP) (Host)
    FTP IP   -connect->
    user -----;
    pwd ----->    Authentication
    ls -----;
  <-----     current directory Contents
  Current:/home/soft01  /home/soft01
  mkdir demo
  cd demo  /home/ soft01
  put toTom.txt-->
  command executed on FTP client, is FTP command, not operating system
&NBSP;FTP command:
 pwd   Query server's current directory
 ls   directory list of servers
 cd   change the server's current directory
 mkdir create a folder on the server
 lcd l:local Changes the local directory
 get filename transfers the file filename on the host to the current folder
 put filename Transfer file filename from the local current folder to the current directory of the server
 lpwd query host current directory
 lls  change host directory list
 help

4) Tar package (no compression) command
How to pack
TAR-CVF File.tar Folder 1 folder 2
Package Folder 1, folder 2 as a file File.tar
Option-C Create creates
-V View the packaged process, optional
-F file Specifies the target file name for packaging
The folder to which the parameter is packaged
File names, usually ending with. Tar (not automatically added)
TAR-XVF File.tar release File.tar to the current folder
Option-X Release
-v option is less efficient to perform

5) Gzip Compression tool
Gzip Demo.tar compress Demo.tar to demo.tar.gz
Delete source files at the same time Demo.tar
gzip-d demo.tar.gz release demo.tar.gz to Demo.tar

Linux tar commands provide convenient-Z options
Can be directly packaged and compressed at the same time
Example: Tar-cvzf demo.tar.gz Demo ABC
The Unix tar command does not have this option
Tar-xvzf demo.tar.gz

6) Zip compression tool command
Zip-r File.zip Folder 1 folder 2
-R means to recursively handle all folders and subfolders
File.zip Package-generated files
Folder 1 Folder 2 is a compressed file that is packaged
Unzip File.zip release File.zip to the current folder

7) Output redirection >
The result of LS/>test.txt LS/command is sent to the Test.txt file and is no longer output to the console
Console console: Is the character interface screen

5. Environment variables: Some variables that can be defined in the Linux system
Path variable: is the operating system executable command search Path
When the operating system executes the command, it searches through the path specified by path and executes if the command is found.
Otherwise, there's an error that the command didn't find.

Echo Echoing command
Echo Echoing content: display echo content to the screen
ECHO ABC shows ABC on the screen
$PATH $ read the value of an environment variable
echo $PATH Display the values of environment variables
Echo Abc>hi.txt
Echo Def>>hi.txt

Export for modifying environment variables
Usage 1:
Export Path= Value
Usage 2:
Path= value
Export PATH
Export path= $PATH:/sbin in the original path is increased/sbin

6.profile File: System initialization script file, this file is executed automatically at the beginning of the system. You can start the system
The execution of the global command is performed automatically on the inside. Changes such as Path
The profile file has two levels, system level, and current user. The system profile is in/etc/profile
Can only be operated by the system administrator (root user)
The current user can only change user-level profile
~/.bash_profile

Mans

GNU = GNU Not Unix
gnu.org

C + C Packing Directory


Linux file system is equivalent to a Windows file system with only a C drive and C: does not exist

md5sum Display file summary, security algorithm
As a summary of the data, the file content must be the same

Linux file system architecture and commands

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.