I Basic Linux
I Basic Linux
Learning to work with Command Line Interface (CLI) is a skill needed in order to
proficiently administer Linux Systems, all of the configurations will be done using CLI. Thus,
succeeding lectures will be more focused on basic Linux commands used in CLI environment. The
initial step in order to learn Linux administration is to be familiarized to different directories.
Procedures:
1. Open CentOS in Oracle VirtualBox
2. Go command line interface by right clicking on desktop, in options provided choose Open in
terminal.
3. In command line, type in cd / (change directory to root) and ls (list).
Take note:
All of the hardisk present in Linux system (C: D: etc.) are collated under the root directory (/).
You have to understand what are the significant of such directories (folder) in Linux System.
The reason why it is being categorized into two user, regular and superuser is to give the regular
user a certain binaries to be executed. There are commands that cannot be used by the user, so it should
be then categorized.
1. bin – binaries for regular users (It can also be executed by admin)
2. sbin - binaries for the superuser/ root user
3. home – home directory of regular users
Take note that Linux is intended by multi-user environment, just like window:
In windows,
C:\user\karlo\
C:\user\minlee\
In Linux,
Same thing goes with Linux:
karlo/home/karlo
minlee/home/minlee
All of the content of the directories are tend to be non-distractive, it means that once you have
restarted your Linux PC, its content will not be deleted except for /proc. The said directory contains
temporary files for the purpose of viewing the system processes (same as task manager in windows
operating system)
Absolute Path - File location with respect to the root directory (/)
Example in windows:
C:\users\john\my documents\my pictures \ bora 2017 \ myprofilepic.jpeg
/home/john/my documents/my pictures/bora/myprofilepic.jpeg
What to Learn?
• New Folder
• Copy Paste File
• Copy Paste Folder
• Cut and Paste File
• Cut and Paste Folder
• Rename File
• Rename Folder
• Delete File
• Delete Folder
• Present Working Directory
• Change Directory
• Up one directory
• Listing Files
#mkdir /sampledir
VERIFY: #ls ls – list all contents of the current
#clear - > to clear terminal directory
Go to /sampledir • Linux has autocomplete feature
#cd /sampledir
VERIFY: # pwd you can also do ls in
remote directory
✓ CREATE THESE DIRECTORIES ls <directory name>
• Dir1
• Dir2 Linux has history function, use up arrow
• Dir3 to go to the previous command. You
• Dir4 can also do ls in remote directory
• Dir5 ls <directory name>
• File1
• File2 2 ways to verify:
#ls – you have to be inside the
• File3
/sampledir (Relative Path)
• File4
• File5 #ls /sampledir (Absolute Path)
#touch <filename>
#touch file1
#verify
#ls
RELATIVE PATH:
*Before using relative path, you have to make sure that you are inside their parent directory
#pwd
#cp file1 dir1
# VERIFY: ls dir1
ABSOLUTE PATHS:
RELATIVE PATH:
#cp file2 dir3/file2copy
#VERIFY
#ls dir3
#ls /sampledir/dir3
ABSOLUTE PATH:
#cp –r /sampledir/dir2 /sampledir/dir5/dir2copy
RELATIVE PATH:
#cp –r dir2 dir5/dir2copy
VERIFY:
#ls /sampledir/dir5
#ls dir5
SYNTAX:
#mv <source> <destination>
ABSOLUTE PATHS
RELATIVE PATH
#pwd
#mv file1 dir2
ABSOLUTE PATH:
#mv /sampledir/file2 /sampledir/dir5/file2cut
RELATIVE PATH:
#pwd
#mv file2 dir5/file2cut
VERIFY:
#ls /sampledir/dir5
#ls dir5
SYNTAX:
#mv <source> <destination>
*no need to type in –r
SCENARIO:CUT dir1 PASTE INTO dir4, retain file name
ABSOLUTE PATHS:
#mv /sampledir/dir1 /sampledir/dir4
RELATIVE PATHS:
#pwd
#mv dir1 dir5
ABSOLUTE PATH:
#mv /sampledir/dir2 /sampledir/dir3/dir2cut
RELATIVE PATH:
#pwd
#mv dir2 dir3/dir2cut
#mv <original filename> <new filename> =cut and paste with a new filename
RELATIVE PATH:
#mv file3 file3new
#VERIFY
#ls sampledir
ABSOLUTE PATHS:
#mv /sampledir/dir3 /sampledir/dir3new
VERIFY: # ls sampledir
#rm <filename>
ABSOLUTE PATH:
#rm /sampledir/file4
RELATIVE PATH:
#rm file4
✓ DELETING DIRECTORIES
SYNTAX:
#rmdir dir3new
CHAPTER EXERCISE:
1. GO TO /
2. CREATE A NEW DIRECTORY /practicedir
3. GO INTO /practicedir
4. CREATE THESE DIRECTORIES
a. dir1
b. dir2
c. dir3
d. dir4
e. dir5
5. CREATE THESE FILES
a. file1
b. file2
c. file3
d. file4
e. file5
6. COPY file1 TO dir1, RETAIN FILENAME
7. COPY file2 TO dir2, GIVE A NEW FILENAME copiedfile2
8. COPY dir1 TO dir5, RETAIN FILENAME
9. COPY dir2 TO dir4, GIVE A NEW FILENAME dir2copy
10. CUT file2 PASTE TO dir1, RETAIN FILENAME
11. CUT file3 PASTE TO dir4, GIVE A NEW FILENAME file3cut
12. CUT dir3 PASTE TO dir4, RETAIN FILENAME
13. CUT dir1 PASTE TO dir2, GIVE A NEW FILENAME dir1cut
14. RENAME file4 TO file4new
15. RENAME dir4 TO dir4new
16. DELETE file5
17. DELETE dir3