LS,CD of Linux basic file management commands

Source: Internet
Author: User
Tags parent directory

Linux provides a number of commands that can be used to simplify our work, perhaps in the graphical interface to click on the mouse more than 10, and in the Linux system, a command can be easily resolved. Therefore, it is necessary to work on a Linux system using the commands provided by the system. To really understand Linux systems, you have to learn from Linux commands.

The command format in a Linux system is generally as follows:

Command format: Command options parameter options: Short options:-Multiple options can be combined:-a-b =-ab long option:--parameters: The object of the command

Here are the main instructions for how to use LS and CD commands

ls command

The LS command is one of the most commonly used commands under Linux, and it is an abbreviation for the English list;

The default LS is used to display the current directory listing, and if you specify a different directory, the list of files and folders in the specified directory is displayed.

Use the LS command to view

  • Files included in the Linux folder

  • File permissions (read, write, execute), including the owner, genus Group

  • Size and type of file

  • Time the file was last modified


1) command format

ls [options] [directory name]


2) Command function

List all subdirectories and files in the destination directory


3) Common parameters

Ls

-L: Details the file name, permissions, owner, file size, etc.

[Email protected] etc]# ls-l total 1172-rw-r--r--.  1 root root 11:02 adjtime-rw-r--r--.  1 root root 1512 Jan aliases-rw-r--r--.  1 root root 12288 June 9 06:52 aliases.dbdrwxr-xr-x. 2 root root 4096 June 9 06:47 Alternatives ...

What about here? The second line shows the total number of files, total 1172

The details of each file are displayed starting from the third line

First column first is the type of file

File type: the

-: Normal file (f)

d: catalog file

B: Block device files (blocks)

C: Character device file (character)

L: Symbolic Link files (symbolic link file)

P: Command pipe file (pipe)

S: Socket file (socket)

The last end of the first column from the second to the first column ends the permission for the file

File permissions: 9-bit, each 3-bit group, each group corresponding, belong to the group; other; permissions, each group: rwx (Read, write, execute), r--"-" means no permission

Each subsequent column represents the file's

the number of hard links to the file; The owner of the file, the genus Group of the file (group), and the file size (size), in bytes;

Timestamp (timestamp): Last Modified Time

Access: Access

Modified: Modify, the file content has changed

Change: change,metadata, meta data (mainly refers to the owner of some files, time, permission information modification time)

-H: Do unit conversions, list file sizes in easy-to-understand format (e.g. 314m,4g)

-A: Lists all files in the directory, including hidden files that begin with the. Start of a hidden file under the Linux system.

. Represents the current directory

: Represents the parent directory

-A: Same-a, but does not list "." and ".".

-D: Display the directory's own properties

-i:index node, which lists the inode numbers for each file

-R: Reverse Display

-R: Recursive (Recursive) display, which lists subdirectories of all files

-S: Sort by file size

-T: Sorting by file modification time


4) Common examples

Example one: List the details of all files and directories under the/etc/sysconf folder

Command:

[[email protected] etc]# ls-l-r/etc/sysconfig or use [[email protected] etc]# Ls-lr/etc/sysconfig

Example two: List the details of all the directories in the current directory that begin with "s", including the table of contents

Command:

[Email protected] etc]# ls-ld s*

5) expansion

Using the LS display file is not displayed by default, some systems use the command alias method to define the "ls" command as "LS--color=auto" can be entered in the Terminal alias view, where each file shows the color corresponding to the following meanings:

Blue: Folder

Red: Compress files

Green: Executable file

White: Text File

Flashing red: Wrong symbolic link

Light green (i.e. pale blue): Symbolic link

[[email protected] ~]$ alias alias l.= ' ls-d. *--color=auto ' Alias ll= ' Ls-l--color=auto ' Alias ls= ' ls--color=auto ' Alias Vi= ' vim ' Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde

Here we also see that "Ls-l--color=auto" is defined as "ll" so we can use the "ll" command to view the directory directly




CD command

The CD command can be said to be the most basic command statement in Linux, the other command statements to operate, are based on the CD command.

1) command format

CD [Directory name]

2) Command function

Switch the current directory to the directory you specified

3) Common examples

Example one: Enter the/etc/sysconfig directory

[Email protected]/]# Cd/etc/sysconfig/[[email protected] sysconfig]#

Example two: Enter the user's home directory

[Email protected] sysconfig]# CD ~[[email protected] ~]#

Example three: Entering the root directory

[Email protected] ~]# CD/[[email protected]/]#

Other:

CD-: Returns the directory where it was before entering this directory

Cd.. : Back to the previous level of the directory, you can always use the command until you return to the root


This article is from the "Small Monk" blog, please be sure to keep this source http://xseng.blog.51cto.com/2513398/1533283

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.