Linux security essentials: Shell and some basic commands

Source: Internet
Author: User
Tags file permissions security essentials

1. What is a shell?
The shell is the interface between the user and the Linux operating system.
There are multiple shells in Linux, with bash being used by default.

Classification of 2.shell
(1) Bash
The bash Shell is a free version of the Bourne shell, which is the oldest Unix shell, including many additional features. Bash has an editable command line that can be checked back to the history command, enabling tab completion to prevent users from entering long file names.
(2) CSH
C Shell uses the "Class C" syntax, drawing on many of the features of the Bourne shell, except that the internal shell command set is different.
(3) Ksh
The syntax of the Korn shell is the same as the Bourne shell, with the easy-to-use features of the C shell. Many of the installation scripts use Ksh, and you should install it on your system even if you do not take it as your primary shell.
(4) Tcsh
The TC shell is an enhanced version of the C shell and is fully compatible with the C shell.
(5) Zsh
The Z shell is an enhanced version of the Korn shell, with many features of the bash shell.


3.shell Foundation
(1) The default shell of the Redhat Linux system is bash.
(2) For ordinary users to use $ as a prompt for super users with # as a hint.
(3) View Shell:cat/etc/shells supported by the current system
(4) View the current bash version: Echo $
(5) View the current Shell version information: Bash--version


How to use the 4.shell console
(1) What is console console?
The console is a human-computer interface that uses the character-manipulation interface.
(2) Operation console
Linux typically has 6 virtual consoles
Press ctrl-alt-(F1-F6) to implement the Virtual Console selection. F2 to F5 is the command line interface, F1 is a graphical interface.
After switching from one console to a new Virtual Console, Linux also displays the login prompt, just like the first time you log in. The user name and password are also queried before loading another command interpreter. As a result, we can log in from different consoles as different users, which makes it easier to perform specific actions with specific identities. When the user switches from a virtual Console to a new virtual Console, the program running on the original console will continue to run.
(3) Advantages of Virtual Console
You can switch to another Virtual Console to terminate this process when a process error locks the input.
(4) If you want to start and not let the system in the graphics login, directly into the character state, you can modify the/etc/inittab file implementation, the method is as follows (KDE operation):
The Vim/etc/inittab file sees the following:
#
# Inittab This file describes how the INIT process should set up
# The system in a certain run-level.
#
# Author:miquel van Smoorenburg,
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#
  
# Default RunLevel. The runlevels used by RHS is:
# 0-halt (do not set Initdefault to this)
# 1-single User mode
# 2-multiuser, without NFS (the same as 3, if you don't have networking)
# 3-full Multiuser mode
# 4-unused
# 5-x11
# 6-reboot (do not set Initdefault to this)
#
Id:5:initdefault:
  
Change the last line of the above 5 to 3, you can let the system is not under the graph landing, to the other several numbers I also make a brief introduction:
0: Downtime (do not set to start the default level)
1: Single-user mode
2: Multi-user, no NFS (this level is the same as 3 if you do not configure the network)
3: Full multi-user mode
4: Do not use
5: Graphics mode
6: Restart (do not set to start the default level)


5. The system's login process
BIOS boot boot phase: Mount the boot manager from the MBR and run the boot-boot management.
Grub as an example starts the boot phase: reads the/boot/grub.conf file and displays the boot menu
Kernel Stage: Mount the root file system
Sys V init initialization phase: Start the/sbin/init program and read the/etc/inittab file


6. Basic commands
(1) LS command
Ls-a View the hidden files that display the general file and the. Start
Ls-l View more detailed file information to view file permissions.
Ls-f add a symbol after the name of the file or directory listed, such as the executable file plus *, the directory is added/.
(2) CD command
commands for entering and exiting the directory.
CD cd~ Back to home directory
CD-Back to the previously manipulated directory
Cd.. Go back to the previous level directory
CD/back to the root directory
Cd.. /.. /go to the top level two directory
(3) mkdir command
Create a file
Mkdir-p/abc/bc/a Multi-level catalog creation
Touch 1.txt Create a new TXT file named 1
(4) RmDir command
Delete an empty directory that already exists
(5) MV move directory or rename files
Mv/tmp/xx.txt/root Move the Xx.txt file under the TMP directory to the root directory
MV Xx.txt yy.txt Rename Xx.txt to Yy.txt
(6) CP command
Copy a file or folder
Cp-r Source File Destination file
Example: CP/ABC/1.TXT/CD copy 1.txt from ABC folder to CD
-R is a recursive copy along with subdirectories.
(7) RM command
Delete File command
The rm-i system will ask us if we want to delete the file.
Rm-r is deleted along with subdirectories
Rm-f forcibly deleting files without confirmation
(8) Cat command
Display or link a generic ASCII text file
Cat A.txt Display A.txt The contents of this file
Cat a.txt b.txt display a.txt b.txt in sequence
Cat A.txt b.txt>c.txt The content of A.txt B.txt and redirects it to c.txt.
Cat-n Display Line numbers
Cat-b Blank lines do not display line numbers
CAT-A Display Tabs
Head-n 5 Ip.txt Display the first 5 lines of the Ip.txt file
Tail-n 5 Ip.txt Show the following 5 lines in the Ip.txt file
PWD Displays the current path
More displays a generic text file that can be paged. than the cat ideal.
(9) User and user group management commands
New user and delete user
Useradd user name-P 123
Userdel User Name
New combined Delete Group
Groupadd Group Name
Groupdel Group Name
passwd Change Password
Super users can change the password of other users
passwd Other User user names
(ten) The difference between Su su-and sudo
SU: The environment variable does not change, not with the root environment variable. Leave the current user status exit.
su-: Switch all over, using the root environment variable
sudo: Temporarily increase the command permissions
(11) Summary of file permissions
User host Group Other
R is the Read permission with a value of 4
W is write permission with a value of 2
X is an executable permission with a value of 1
The rwx is a readable writable executable.
RWS is a temporary elevation of privilege execution.
RWT can be read and writable and cannot be deleted.
(chmod) command
Commands to modify permissions for a directory or file
chmod u+x ip.txt to IP this file plus executable commands.
Chmod-r recursive weighting or lowering of weights
(13) Process and task management commands
PS Command-----The most basic and powerful process view command
PS-E Show All Processes
-F Full format
-L Long format
The top command-----dynamically display process information
Zombie Zombie process, hanging dead process
WA I/o read/write
ID CPU free Space
Kill command-----Delete a process
Kill-q Force Delete
Killall httpd Delete all httpd processes
(14) disk and file System management commands
DF View Disk Utilization
-K Displays the disk space remaining on the current disk
-H shown to conform to human reading habits
Du view File size

Linux security essentials: Shell and some basic commands

Related Article

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.