Basic Linux operations and simple trials

Source: Internet
Author: User

I. Basic operations
Ø directory operations
① View the Home Directory
Enter the pwd command to display your home directory. For example:/home/arm
② View the directories and files in the main directory in long format
Enter the ls-l command to display all the files in the main directory, including the file attributes, size, and creation time.
Ø File Operations
① Create an empty file and view its attributes;
Enter the touch test command to create an empty file named test;
Enter the touch test1 command to create an empty file named test1;
Run the ls-l command to view the properties of the file you just created. The property value is-rw-r --.
② Use chmod 777 to change the attributes of the file, and then view the attributes;
Enter the chmod 777 test command to change the attributes of the file;
Run the ls-l command to view the file attributes after changing the file attributes. The property value is-rwxrwxrwx.
③ Delete the file.
Enter the rm test command to delete the test file;
Run the ls-l command to check whether the deletion is successful.
Ø copy operation
① Create a new subdirectory "hello" in the main directory;
Enter the mkdir hello command to create the hello directory;
Run the ls-l command to check whether the creation is successful.
② Copy the previously created file test1 to the hello subdirectory in the home directory;
Run the cp-a test1 hello command to copy the file;
Enter the cd hello command to enter the hello directory;
Run the ls-l command to check whether test1 exists and check whether the copy is successful.
Ii. Basic Linux programming Experiment
① Use the vi editor to create the following files (for instructions on using the vi Editor, see "Vi editor full user manual ")
Enter vi in the main directory to enter the vi text editor. The first step is to enter the edit mode. Enter I and enter the insert mode to write the code. Copy the following program 1 directly. Click ESC, enter wqhello. c, save the file as hello. c, and exit the vi editor.
 
Program 1: hello. c
# Include <stdio. h>
Intmain (void)
{
Printf ("Hello world, Linux programming! \ N ");
Return 0;
}
 
Run the following command to compile the program:
# Gcchello. c-o hello
Check whether the executable file hello is generated.
Run:
#./Hello
View the program execution result.
Result: Helloworld, Linux programming!
② Step-by-step compilation hello. c:
Run:
# Gcc-E hello. c-o hello. I
Observe the content of hello. I.
Run
# Gcc-c hello. I-o hello. o
Check whether hello. o is generated.
Generate the hello. o file
# Gcchello. o-o hello
Check whether hello is generated
Generate a hello File

Author: Yang Qi (sihu)

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.