Summary of basic Bash shell commands

Source: Internet
Author: User

Here's what you'll find useful after reading the third chapter of the Linux command line and Shell script programming encyclopedia.

1./ETC/PASSWD file

  This file contains a list of all system user accounts and basic configuration information for each user, as shown in:

  

 Each entry has seven fields, and the fields are separated by a colon, which includes:

• User Name

• User password (if the password is in another location, the bit is a placeholder)

• User's system UID

• User's system GID

• The user's full name

• Default home directory for users

• User's default shell program

2.shell prompt

 The default bash shell prompt is $, and the prompt can be changed as follows:

[[Email protected]~]#

Root: User name to start the shell

Centos-net: Current Virtual Console number

~: Current directory, this "~" is the abbreviation for the home directory "/root"

3. File system

 Linux store files in a single directory structure---virtual directories that contain the file paths of all storage devices installed on the PC and incorporate them into a directory structure

The Linux virtual directory contains an underlying directory for the root directory (/root)

• The first hard drive installed on a Linux PC is the root drive, which contains the core of the virtual directory, and the other directories are built from there

Linux creates special directories on the root drive called mount points, which are directories in the virtual directory that are used to allocate additional storage devices.

• Usually the system files are stored in the root drive, and the user files are stored in a different drive, such as:

4. Common Linux Directories

  /: Root directory

/bin: Binary directory, storing GNU user-level tools

/boot: Start directory, hold startup file

/dev: Device directory, where device nodes are created

/etc: System configuration file directory

/home: Master directory, where user directories are created

/lib: Repository File

/MNT: Mount Directory

/root: Root Home directory

/sbin: Binary directory of the system, storage of GNU management-level tools

/tmp: Storing temporary files

/usr: User Install software directory

/var: variable directory, storing frequently changing files

5. ls

commonly used parameters:

-A: Show hidden files along with normal files and directories

-R: Traverse directory, show All

-L: Output shown in long list format

-H: Print size

-I: Displays the index value of each file ( index value: The index node of a file or directory is a unique identifying number that the kernel assigns to each object in the file system )

-S: Output block size per file

6.cp

♦ Example

  

 The index node numbers for 2.sh and 1.sh are different, and the modification times are different.

♦ Common parameters:

-F: Force overwrite files that already exist without prompting

-R: Copying files recursively

-r: Recursively copy directories, for example: Cp-r dir1 Dir2

-L: Create a hard link

-S: Create symbolic links, i.e. soft connections

7.mv

  

 2.sh and 4.sh have the same index node number and timestamp

8.rm

  Common parameters:

-R: Recursively deletes the files in the directory and finally deletes the directory itself

-F: Do not prompt

9. Hard links and soft connections

♣ Create

 

2.sh is a hard link for 1.sh, and the index node number and attributes are consistent

3.sh is a symbolic link of 1.sh, that is, soft joins, different index nodes, different attributes, smaller files

♣ Removal

 2.sh has no change, but 3.sh points to an invalid file that is no longer a link.

♣ Delete

 

* * The hard-link file takes the same index node number as the source file; the hard link maintains the index node number to preserve the data, knowing that you deleted the last hard-linked file.

10. Commands to view the contents of a file

 Stat: Provides all state information for a file on a file system

File: Types of files to check

Cat: Check the file contents, available Parameters-N,-B;-N is the line number for all lines,-B is only for lines with text line number

Tail: Default display of the end of the file 10 lines

Available parameters:-C bytes Displays the last bytes characters of the file,-N lines displays the last lines line of the file

Head: Default display of the first 10 lines of the file, available parameters:-C bytes,-n Lines

        

Summary of basic Bash shell commands

Related Article

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.