Getting Started with Linux basics

Source: Internet
Author: User
Tags touch command

Create a Directory

To create a directory using the mkdir command

mkdir $HOME/testFolder
Switch directories

Switch directories using the CD command

cd $HOME/testFolder

Use CD: /Command switch to the previous level directory

cd ../
Move Directory

To move a directory using the MV command

mv $HOME/testFolder /var/tmp
Delete Directory

To delete a directory using the RM-RF command

rm -rf /var/tmp/testFolder
View the files in the directory

Use the LS command to view all files and folders in the [/etc] Directory

ls /etc

/etc directory default is the *nix system's software configuration file storage location

File operations

Task time: 5min ~ 10min

Create a file

Create a file using the Touch command

touch ~/testFile

To execute the ls command, you can see the newly created Testfile file

ls ~
Copying files

Copying files using the CP command

cp ~/testFile ~/testNewFile
deleting files

Use RM command to delete file, enter to y confirm Delete

rm ~/testFile
View File Contents

Use the cat command to view the contents of the. bash_history file

cat ~/.bash_history
filtering, piping and redirection

Task time: 5min ~ 10min

Filter

Filter out the records contained in root the/etc/passwd file

grep ‘root‘ /etc/passwd

Recursively filter out records contained in the/var/log/directory linux

grep -r ‘linux‘ /var/log/
Pipeline

In short, the role of the pipeline in Linux is to input the output of the previous command as the next command, concatenating the commands in series like a pipe, and the pipe operator is |

For example, we can combine the cat and grep two commands with a pipeline

cat /etc/passwd | grep ‘root‘

Filter out the directories contained in/etc directory ssh (excluding subdirectories)

ls /etc | grep ‘ssh‘
redirect

You can use > or < to redirect the output of a command to a file

echo ‘Hello World‘ > ~/test.txt
Operation and maintenance of common commands

Task time: 5min ~ 10min

ping command

Send 4 ping packets to cloud.tencent.com to check for connectivity

ping -c 4 cloud.tencent.com
Netstat command

The netstat command is used to display various network related information, such as network connection, routing table, interface status, etc.

List all TCP ports in the listening state

netstat -lt

View all port information, including PID and process name

netstat -tulpn
PS command

Filter to get the SSH process information in the current system

ps -aux | grep ‘ssh‘

Getting Started with Linux basics

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.