Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

REVIEW COMMAND LINUX

By.SOK KIMHENG
March 09, 2020

● / :​ Forward slash is called “Root Directory”


root directory is the top directory of all directory, in linux there is only one root directory,
while in windows operating system there could be several root directory such as: Drive C:/, D:/,
E:/, F:/

Under the “/” root directory there are several working directory like:

● /etc:​ store all the configuration files


● /bin:​ store binary or executable files
● /usr​: store user related files such as library, sharing
● /usr/bin:​ store all the binary or executable files install by user
● /home:​ store all the user of the system
● /home/USERNAME:​ is called home directory which is the user working space that
contains “Documents”, “Desktop” … it is also represent as “~”
● cd​ VS​ ls: ​there are two ways to view directories and files directly or indirectly. For
example what are the directories and files in ​/bin ?
○ View directly
■ cd /bin
■ ls
○ View indirectly
■ ls /bin
● “​|​”: This is called pipe, it is used for process communication. Output of the first command
becomes the input of the second command. For example:
○ ls /bin | less //show output line by line
○ ls /bin | more //show output screen by screen
○ ls /bin | grep “chmod” //see if “chmod” command locate in /bin
○ ls /usr/bin | grep “gcc” //see if “gcc” command locate in /usr/bin
○ ls -l ~ | awk ‘{print $9}’ //print the 9th column of the output ls -l ~
● All command is an application and usually it is located at /bin or /usr/bin, if you type any
command and it shows “command not found”, which means your PC doesn’t have that
command and you need to install it in order to use it. (Make sure you have Internet
connection)
○ sudo apt-get update //update to the latest package management
○ sudo apt-get install ………….. //install any software
● Cloning code from github
○ sudo apt-get install git //install git software
○ cd ~ //goto home directory
○ mkdir os_course //create folder os_course
○ cd os_course //change directory to os_course
○ sudo git clone ​https://github.com/KimhengSOK/process.git​ //clone code from my
git online directory
○ ls //view download directory you will see
“process” folder
○ cd process //go into process folder
○ ls //there are 4 c programming files
● GUI, CLI​: Normally, we have two Interface for User to communicate with Machine
○ Graphic User Interface
○ Command Line Interface
We can use command line interface (Ubuntu Terminal) to compile our c program, but we
need one software called “gcc” . It is a c compiler which is a program that compile c program file
to binary file. If you don’t have it, use apt-get install to install it.
● There are two ways to compile c program
○ Two steps compile
■ sudo gcc -c p1_process.c //this will create object file p1_process.o
■ sudo gcc p1_process.o -o p1_process //get binary file from object
file
○ One step compile
■ sudo gcc p1_process.c -o p1_process //get binary file from source file
● To run the program
○ ./p1_process

You should have known all of this since semester I, if you don’t you need to work harder do
self-study in the link below.

Reference:
https://ubuntu.com/tutorials/command-line-for-beginners#1-overview

You might also like