Learn more about Linux commands

Source: Internet
Author: User

[Email protected]:/home/wuheng# ls-l
Total 44
Drwxr-xr-x 2 Wuheng Wuheng 4096 Mar 3 01:30 Desktop
Drwxr-xr-x 2 Wuheng Wuheng 4096 Mar 3 01:30 Documents
Drwxr-xr-x 2 Wuheng Wuheng 4096 Mar 3 01:30 Downloads
-rw-r--r--1 Wuheng Wuheng 8980 Mar 3 09:23 examples.desktop
Drwxr-xr-x 2 Wuheng Wuheng 4096 Mar 3 01:30 Music
Drwxr-xr-x 2 Wuheng Wuheng 4096 Mar 3 01:30 Pictures
Drwxr-xr-x 2 Wuheng Wuheng 4096 Mar 3 01:30 public
Drwxr-xr-x 2 Wuheng Wuheng 4096 Mar 3 01:30 Templates
Drwxr-xr-x 2 Wuheng Wuheng 4096 Mar 3 01:30 Videos

1.D, Representative directory

2.rwxr-xr-x, which is the permissions of the file or directory to the owning user, the same group of users, and other users

3. The first: Wuheng represents the file belonging to the user Wuheng

4. Second: Wuheng represents the file belonging to the user group Wuheng

5.4096, which indicates that the file size is 4096 bytes.

6.Mar 3 01:30 represents the date and time when the file was last modified.

7. The last one is the name of the file/folder. For example, desktop

[Email protected]:/home/wuheng# lsblk-l
NAME maj:min RM SIZE RO TYPE mountpoint
SDA 8:0 0 20G 0 disk
SDA1 8:1 0 19G 0 Part/
Sda2 8:2 0 1K 0 part
Sda5 8:5 0 1022M 0 part [SWAP]
Sr0 11:0 1 1024M 0 rom

Lsblk-l command to display block devices in list format (not tree format)

Note:lsblk is the most useful and easiest way to learn the name of a newly inserted USB device, especially when you are working on a disk/block device on a terminal.

[Email protected]:/home/wuheng# uname-a
Linux wuheng-virtual-machine 4.2.0-27-generic #32 ~14.04.1-ubuntu SMP Fri Jan 15:32:26 UTC x86_64 x86_64 x86_64 GNU /linux

uname, that is, "Linux Name".

Note: uname Displays the kernel category, uname-a displays details. the above output details the uname-a

[Email protected]:/home/wuheng# history
1 apt-get Install Mysql-server mysql-client
2 Apt-get Install Apache2
3 Apt-get Install PHP5 LIBAPACHE2-MOD-PHP5
4 chmod 777/var/www/
................

History "The command is a historical record. It shows the history of all commands executed in the terminal.

[Email protected]:/var/www/html# Touch a.txt
[Email protected]:/var/www/html# ls
A.txt index.html phpMyAdmin wh.tar.gz

The "Touch" command represents the update of the file's access and modification times to the current time. Touch The command will only be created when the file does not exist.

If the file already exists, it updates the timestamp, but does not change the contents of the file.

The "chown" command changes the owner of the file and the user group. Each file belongs to one user group and one user. In your directory, use "ls-l" and you will see something like this.

[email protected]:/var/www/html# ls-l
Total
Span style= "color: #ff0000;" >-rw-r-xr-x 1 Wuheng root     0 mar  9 19:22 a.txt
-rwxrwxrwx 1 root   Root 1 1510 mar  9 19:21 index.html
lrwxrwxrwx 1 root   root    Mar  3 18:46 phpMyAdmin -/usr/share/phpmyadmin
-rw-r--r--1 root   root   249 mar  9 19:21 wh.tar.gz

where , A.txt belongs to User: Wuheng, belongs to user group:root;  index.html belongs to User: root, belongs to user group: root.

[Email protected]:/var/www/html# chown root root a.txt
Chown:cannot access ' root ': No such file or directory
[Email protected]:/var/www/html# ls-l
Total 16
-rw-r-xr-x 1 root root 0 Mar 9 19:22 a.txt
-rwxrwxrwx 1 root root 11510 Mar 9 19:21 index.html
lrwxrwxrwx 1 root root 3 18:46 phpMyAdmin-/usr/share/phpmyadmin
-rw-r--r--1 root root 249 Mar 9 19:21 wh.tar.gz
[Email protected]:/var/www/html#

Now, A.txt belongs to User: root, belongs to user group: root.

"Copy" is the copy. It copies one file from one place to another.

[Email protected]:/var/www/html# cp a.txt demo/
[Email protected]:/var/www/html# ls
A.txt Demo index.html phpMyAdmin wh.tar.gz
[Email protected]:/var/www/html# CD Demo
[Email protected]:/var/www/html/demo# ls
A.txt

The "mv" command moves a local file to another location.

[Email protected]:/var/www/html# Touch a.txt
[Email protected]:/var/www/html# ls
A.txt Demo index.html phpMyAdmin wh.tar.gz
[Email protected]:/var/www/html# mv A.txt demo/
[Email protected]:/var/www/html# ls
Demo Index.html phpMyAdmin wh.tar.gz
[Email protected]:/var/www/html# CD Demo
[Email protected]:/var/www/html/demo# ls
A.txt

pwd"(Print working directory), which displays the full path of the current working directory in the terminal.

[Email protected]:/var/www/html/demo# pwd
/var/www/html/demo

Learn more about Linux 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.