Linux common and commonly used commands (1)


提示:以下是本篇文章正文内容

1. Commands related to who

Order Functional description
whoami Display the current user's login name
who am i Display the login name, terminal name, and login time of the current user. If you log in remotely, the IP address will be displayed
who Display information about all users currently logged into the system, including login name, terminal name, and login time. If you log in remotely, the IP address will be displayed. [-q] Only display the login user name and the total number of login users
w 1. Display the information of all users currently logged into the system, including login name, terminal name, login location, login time, idle time and what command is currently being executed. 2. It also displays the current system time, how long the system has been started, how many users have logged into the system, and the average load value of the system in the past 1, 5, and 10 minutes.

Two, the date command

1. Command format

 date  【选项】+【格式】

2. Function description

  • Display or set the current date and time of the system.
  • Set the format of the date: MMDDhhmmYYYY[.ss].
  • –date=string: Display the time described by the specified string instead of the current time.

3. Function demonstration

insert image description here

Three, cal command

1. Command format

cal [月] [年]

2. Function description

  • Display the calendar.
  • If month and year are not specified, the calendar of the current month of the current year will be displayed.
  • If only one number is specified, it will be treated as a year rather than a month.
  • The year must be expressed in AD years.

Four, uptime command

1. Command format

uptime

2. Function description

  • Display the current system time, how long the system has been started, how many users have logged into the system at present, and the average load value of the system in the past 1, 5, and 10 minutes.

Five, history command

1. Command format

history [n]

2. Function description

  • List all previously executed commands, numbered. The executed commands are saved in the .bash_history file in the current user's home directory by default, and a maximum of 1000 commands are saved by default.
  • n is a number, and only the N commands that have been used recently are listed, such as: history 20.
  • "!Command Number" quickly executes the historical commands executed before.

Six, pwd command

1. Command format

pwd

2. Function description

  • Use the absolute path to display the current directory location of the user.
  • The tilde ~ indicates the home directory.
  • /root is the home directory of the super user, and the directory of ordinary users is /home/username/.

Seven, ls command

1. Command format

ls [-a] [-l] [-i] [-h] [-t] [-d] [文件或者目录]

2. Function description

  • Execute the ls command to list the contents of the directory, including the names of files and subdirectories.
    usage:
Parameters added after ls Realize function
file1.txt ls followed by a file name will only display the file name
/etc followed by a directory name will list the contents of that directory
-a Show all content, including hidden files and directories
-l Displays file or directory details (properties) in long format, including file type and permissions, number (number of hard links), user name, user group, file size (bytes), last updated date and time, A total of 7 columns of information for the file name or directory name. This command can be abbreviated as ll.
-i Display the inode, which is the number of the file
-h Display the size of the file in units of K, M, G, etc., usually used together with "-l"
-t Display files sorted by their latest modification time, with the most recently modified files displayed first
-d Display the properties of the directory itself, not the contents of the directory

3. Explanation of the 7 columns of information that appear in the ls -l command:

insert image description here
insert image description hereinsert image description here

The first bit in the first column of information is the type identifier, identifying the type of the file. Among them - means ordinary file, d means directory, l means link file, c means character device file, b means block device file, s means socket file, p means first in first out file.

  • normal file "-"
common file type color representation
text file White
Executable files (binary files, script files) green
Package file (.tar) red
Compressed files (.gz, .bz2) red
Compressed archive files (.tar.gz, .tar.bz2) red
rpm package file (.rpm) red
  • directory "d"
在图形界面中成为文件夹,在字符界面中称为目录。
  • link file "l"

insert image description here
insert image description here

  • character device "c"

insert image description here

  • block device "b"

insert image description here

  • socket file "s"

insert image description here


Guess you like

Origin blog.csdn.net/ATTAIN__/article/details/124208791