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

3.2 Command Line

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

By command line, we mean a text-based interface that allows you to enter commands, execute commands, and view the results of the run. You can run a terminal (the character interface on the graphical desktop or the text console itself outside the graphical interface) and an embedded command interpreter (Shell).

3.2.1 how to enter the command line

When your system starts normally, the easiest way to get to the command line is to run the terminal program in your graphical desktop session.

Figure 3.1 start the GNOME terminal

For example, on the default Kali Linux system, the GNOME terminal can be launched from a favorite application. You can also type "terminal" when the active screen appears (when you move your mouse over the upper left corner), and then click the application icon that appears (see figure 3.1).

If the graphics world is not interrupted, you can still get a command line on the virtual console (you can access up to six consoles through CTRL+ALT+F1 to CTRL+ALT+F6, and you can omit the CTRL key if you are already in text mode, Xorg or Wayland's graphical interface) (Note: Wayland belongs to the same level of things as X Window, not just as an alternative to X Server under X Window. In other words, Wayland is not only going to completely replace X Window, but it will subvert the concept of X Client/X Server on Linux desktops. Maybe there will be no so-called "X Client" but "Wayland Client" in the future. Before accessing the command line and its shell, you will get a basic login screen and enter your login name and honey code here:

Kali GNU/Linux Rolling kali-rolling tty3

Kali-rolling login: root

Password:

Last login: Fir Mar 25 12:30:05 EDT 2016 from 192.168.122.1 on pts/2

Linux kali-rolling 4.4.0-kali1-amd4 # 1 SMP Debian 4.4.6-1kali1 (2016-03-18) x86 million 64

The programs included with the Kali GNU/Linux system are free software

The exact distribution terms for each program are described in the

Individual files in / usr/share/doc/*/copyright.

Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent

Permitted by applicable law.

Root@kali-rolling:~#

The program that accepts input and executes your commands is called shell (or command interpreter). The default shell provided by Kali Linux is Bash (which stands for Bourne Again SHell). The character "$" or "#" at the end indicates that shell is waiting for your input. The last character also indicates whether Bash thinks you are a regular user ($) or a superuser (#).

3.2.2 Command line basics: browse directory trees and manage files

This section provides only an overview of the relevant commands, all of which have many options, which are not detailed here, but can be found in the manuals related to their respective commands. In * testing, when you successfully Exploit, you usually get access to the system Shell, rather than the graphical user interface. Therefore, proficiency in the command line is essential for you to become a successful security expert.

When a session is opened, the pwd command (for print working directory) displays your current location in the file system. The current position can be changed with the cd directory command (cd stands for change directory). When you use cd -, you can go back to the previous working directory (the directory before the last cd command). The parent directory is done by using.. Represents (double-dot), while the current directory is represented by. (single-point). The ls command allows you to list (listing) the contents of a directory. If you do not provide arguments, the ls command lists the contents of the current directory.

$pwd

/ home/buxy

$cd Desktop

$pwd

/ home/buxy/Desktop

$cd.

$pwd

/ home/buxy/Desktop

$cd..

$pwd

/ home/buxy

$ls

Desktop Downloads Pictures Templates

Documents Music Public Videos

You can use the mkdir directory command to create a directory and the rmdir directory command to delete an existing (empty) directory. The mv command allows you to move and rename files and directories; delete a file with the rm file command and copy a file with the cp source-file target-file command.

$mkdir test

$ls

Desktop Downloads Pictures Templates Videos

Documents Music Public test

$mv test new

$ls

Desktop Downloads new Public Videos

Documents Music Pictures Templates

$rmdir new

$ls

Desktop Downloads Pictures Templates Videos

Documents Music Public

Shell finds the first program that matches the given name in the directory list indicated in the PATH environment variable and executes the program. In most cases, these commands are in / bin,/sbin/,/usr/bin, or / usr/sbin. For example, the ls command can be found at / bin/ls, and the which command can give you the directory where the given command is located. Some commands, which can be processed directly by shell, are called shell built-in commands (both cd and pwd); the type command can query the type of each command.

$echo $PATH

/ usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

$which ls

/ bin/ls

$type rm

Rm is / bin/rm

$type cd

Cd is a shell builtin

Note the use of the echo command, which simply displays a string on the terminal. In this case, it is used to print the contents of the environment variable because shell automatically replaces the value of the variable when it executes the command.

Environment variables: environment variables allow you to store global settings for shell or other programs. They are context-sensitive and inheritable. For example, each process has its own collection of environment variables (context-sensitive). For example, login Shell (login shells) can declare variables, and these variables can be passed down to other executable programs (inheritable).

These variables can be defined in a system-wide / etc/profile file, or in each user's unique ~ / .profile file, but variables that are not specific to the command line interpreter are better defined in / etc/environment, because these variables are injected into all user sessions through the pluggable authentication module (PAM)-even without shell being executed.

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

Network Security

Wechat

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

12
Report