Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic operation of Linux

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Goal: master Linux system basic commands Linux basic commands: basic commands: TTY terminal commonly used command prompt information system related commands: view system version view CPU view memory information shutdown operation init 0 restart operation

Why learn the basic Linux commands?

Unlike windows systems, Linux systems are more managed and configured under the command line.

1. Basic Linux commands

1. Basic command

(1) TTY terminal

In the default login mode of Linux, it is mainly divided into two types, one is the login environment with only plain text interface (character interface), and the other is the login environment with graphical desktop. In addition, the Linux system provides six virtual terminals by default to allow users to log in. The six terminals are tty1~tty6. Use the Ctrl + Alt+ (F1~F6) command to switch. F1 is a graphical interface and F2~F6 is a character interface. (on a Linux system with a graphical interface) after F1 is a character interface (minimized installation) switch, you can enter the "tty" command to see which terminal you are currently in.

(2) Common commands

If ① wants to type a command, there are three ways: 1) Open its own terminal, similar to cmd2 under windows) you can enter the character interface 3) remote connection

1. Hostname to view the full name of the current host

At the same time, hostname can also modify the host name of the current system.

New hostname for hostname

Modify the current hostname to xxx (temporarily change hostname)

Logout and exit log out of the current login environment

For example, hostname kfc means that the hostname of the current system is temporarily modified to kfc, and the hostname takes effect after logging out and re-logging in.

The above are temporary changes and will not take effect after restart

To permanently change the hostname, use the following command: vi / etc/sysconfig/network (permanently modify hostname) centos6 version vi / etc/hostname (permanently modify hostname) centos7 version

Press I to enter the input mode, press Esc to exit the input mode after modifying the host name, press "shift+:" and then enter wq, enter and exit the vi editor.

After the modification, the restart takes effect.

Init 6 restart 2, pwd shows the user's current working directory location 3, cd is used to switch the working directory (folder)

(1) absolute path: this method starts with the root directory'/'.

For example,'/ var/log' means the log directory in the varsubdirectory under the root directory; to specify that log is a directory (not a file), you can also add a directory delimiter at the end

If expressed as "/ var/log/'"

Cd / var/log; cd / var/log/

(2) relative path: this method generally starts with the current working directory and does not use the "/" symbol at the beginning. The relative path mainly includes the following forms.

A. Use the directory name directly to indicate the location of the subdirectory in the current working directory; for example, if the current directory is / var, execute cd log to enter the log subdirectory

B, use two periods ".." Start with the parent directory above the current directory as the starting point; for example, the current directory is / var/log, execute cd.. Return to the / var directory

C. Use a period. At the beginning, you can explicitly indicate that you start with the current working directory; for example, the current directory is / var/log, and ". / messages" can represent the messages file in the current directory, which is often used when executing scripts later.

In addition:

Cd ~ or cd go back to the original home directory

~, representing the home directory of the currently logged in user

Cd-switch back to the directory where the last cd command was executed

Cd.. Return to the previous directory

. / current directory

.. path to the parent directory

4. Ls (list) list, which is used to display the contents of the directory (folder) 5, prompt information

What the prompt contains: current user name / host name / directory name / prompt

#: Super Admin status

$: ordinary user identity

Example:

Echo $PS1 (prompt variable)

[\ u@\ H\ W]\ $

Echo printout

Note: U is username (user name), H is Hostname (hostname), W (working directory)

The # sign indicates that the user currently logged in is a Super Admin user. If the person currently logged in is an ordinary user, the "#" character becomes "$"

After the command prompt, you can enter various operation commands in the form of a string, and then enter to indicate that the input is complete and executed.

II. System-related commands

Mainly view the various system information in the Linux host.

1. View the system version

Lsb_release-a View the system version of the current operating system (redhat-lsb-core package is required for centos 7 and above) View release: cat / etc/redhat-release centos6 and 7 View release

2. Check the operating system: uname

3. Check the kernel version: uname-r

4. Check the IP address: ifconfig

5. View CPU information: cat / proc/cpuinfo

6. View memory information: cat / proc/meminfo

8. View hard disk information: df-hT

9. Shutdown operation

Shutdown operation: shutdown-h nowpoweroff (forced shutdown before 5. 0) init 0 delayed shutdown: shutdown-h + minute "prompt content" example: shutdown-h 5 "guanji" cancel: ctrl+c restart operation: shutdown-r nowrebootinit 6

Delayed restart: shutdown-r + min

Cancel delayed operation: ctrl+c;shutdown-c

Exit the current command operating environment: exit

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report