Home > php教程 > PHP开发 > Common Linux commands

Common Linux commands

高洛峰
Release: 2016-11-19 09:38:43
Original
1292 people have browsed it

1. cd

cd ~username: The command is used to switch directories, and can also switch the user's home directory.

[root@localhost ~]# cd ~123

[root@localhost 123]# pwd #View the current path

/home/123

The user’s home directory is a folder created for a specific user. The user The user has ownership of the contents of this folder, but not all programs in the user's home directory belong to the user. The owner of the test2 file below is root, because it is a file created with root permissions, and a test2 with read-only permissions is created on the desktop.

[root@localhost Desktop]# touch test2

[root@localhost Desktop]# ls -l

total 2220

-rw-r--r--. 1 root root 2272130 Aug 6 2013 cacti-0.8. 8b.tar.gz

-rw-rw-r--. 1 123 123 0 Nov 1 03:38 new file

-rw-rw-r-- 1 123 123 0 Nov 17 22:42 new file (copy )

-rw-r--r-- 1 root root 0 Nov 17 23:16 test2

If you log in to the 123 user through su and create a test4 file, its owner belongs to the 123 user and has Read and write permissions.

[123@localhost Desktop]$ su 123

Password:

[123@localhost Desktop]$ ls

cacti-0.8.8b.tar.gz new file new file (copy) test2 test3

[123@ localhost Desktop]$ touch test4

[123@localhost Desktop]$ ls -l

total 2220

-rw-r--r--. 1 root root 2272130 Aug 6 2013 cacti-0.8.8b.tar.gz

-rw-rw-r--. 1 123 123 0 Nov 1 03:38 new file

-rw-rw-r-- 1 123 123 0 Nov 17 22:42 new file (copy)

-rw -r--r-- 1 root root 0 Nov 17 23:16 test2

-rw-rw-r-- 1 123 123 0 Nov 17 23:18 test3

-rw-rw-r-- 1 123 123 0 Nov 17 23:20 test4

2, type

The type of command can be realized through the type command. Commands in Linux are divided into internal commands and external commands.

[123@localhost Desktop]$ type cut

cut is /usr/bin/cut #External command (in a corresponding directory)

[123@localhost Desktop]$ type echo

echo is a shell builtin #Internal command

3, printenv

Through this command, you can view the environment variable information of the system. The environment variable information has the same meaning as the JAVA setting. Among a lot of information, only PATH is the environment variable information. . Newly developed programs must also be set in environment variables.

[root@localhost Desktop]# printenv

ORBIT_SOCKETDIR=/tmp/orbit-123

HOSTNAME=localhost.localdomain

TERM=xterm

SHELL=/bin/bash

XDG_SESSION_COOKIE=2604b 541bf302be0cd47ddec00000011-1479446380.885020-236895646

HISTSIZE=1000

GTK_RC_FILES=/etc/gtk/gtkrc:/home/123/.gtkrc-1.2-gnome2

WINDOWID=46138793

USER=123

LS_COLORS=rs=0:di=01; 34: ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31; 01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex= 01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01; 31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31: *.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*. bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace= 01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01; 35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35: *.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*. svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v= 01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01; 35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35: *.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*. xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx= 01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01; 36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36: *.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:

GNOME_KEYRING_SOCKET=/tmp/keyring-ejyje6 /socket

SSH_AUTH_SOCK=/tmp/keyring-ejyje6/socket.ssh

SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/2354,unix/unix:/tmp/.ICE-unix/2354

USERNAME=123

DESKTOP_SESSION=gnome

MAIL=/var/spool/mail/123

PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin :/sbin:/home/123/bin

PWD=/home/123/Desktop

GDM_KEYBOARD_LAYOUT=us

LANG=en_US.UTF-8

GNOME_KEYRING_PID=2344

GDM_LANG=en_US.UTF-8

GDMSESSION=gnome

SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass

HISTCONTROL=ignoredups

HOME=/root

SHLVL=11

GNOME_DESKTOP_SESSION_ID=this-is-deprecated

LOGNAME=123

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-MMUi3C39vL,guid=b6fecbcb44a8fd92e501ec9b0000003d

LESSOPEN=|/usr/bin/lesspipe.sh %s

WINDOWPATH=1

DISPLAY=:0.0

G_BROKEN_FILENAMES=1

COLORTERM=gnome-terminal

_=/usr/bin/printenv

4 , hash

The hash command is used to display the number of times the command is tapped on the screen. hash -r is used to clear the cache information of this command. When the command used in the hash is used again, it will not be called in the kernel, but will be removed directly from the cached KV (key value) database, which will be very fast.

[root@localhost Desktop]# hash

hitscommand

1/bin/grep

1/bin/vi

1/usr/bin/man

2/usr/bin/printenv

1/usr /bin/clear

5, date

Display the system time. The system time here is the kernel time of the system. The kernel time is the simulated time oscillator for timing. After the system is installed, the hardware time of the host will be read, and then it will Time it yourself. Use date -u month day hour minute year. second to set the system time.

[root@localhost Desktop]# date -u 1118160216.30

Fri Nov 18 16:02:30 UTC 2016

The date command also includes some wildcard options, taking 2016/11/18 as an example, %y=16 ,%m=11,%d=18, when using wildcard fields, + must be added after date.

[root@localhost Desktop]# date

Fri Nov 18 16:11:13 PST 2016

[root@localhost Desktop]# date +%y

16

[root@localhost Desktop]# date +% m

11

[root@localhost Desktop]# date +%d

18

The output effect of changing the letters after the wildcard character to uppercase is like this

[root@localhost Desktop]# date +%Y

2016

[root@localhost Desktop]# date +%M

13

[root@localhost Desktop]# date +%D

11/18/16

date can also output text

[root @localhost Desktop]# date +"today is %d"

today is 18

[root@localhost Desktop]# date +"this year is %Y"

this year is 2016

6、clock,hwclock

As mentioned before, in addition to the date that can check the current time, there is also the hardware time that can be checked through the clock. The clock and date times may be different.

[root@localhost Desktop]# date

Fri Nov 18 16:22:02 PST 2016

[root@localhost Desktop]# clock

Fri 18 Nov 2016 12:22:45 AM PST -0.906975 seconds

The above system time is different from the hardware time. The system time is correct and can be modified through hwclock -w.

[root@localhost Desktop]# hwclock -w

[root@localhost Desktop]# clock

Fri 18 Nov 2016 04:24:43 PM PST -0.141483 seconds

[root@localhost Desktop]# date

Fri Nov 18 16:24:51 PST 2016

There is also a command cal to view the calendar of the current year, cal -y to view the specified year.

[root@localhost Desktop]# cal

November 2016

Su Mo Tu We Th Fr Sa

1 2 3 4 5

6 7 8 9 10 11 12

13 14 15 16 17 18 19

20 21 22 23 24 25 26

27 28 29 30


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template