Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
29 views
7 pages
Reviewer Chapter 0
BSIT, INTEG
Uploaded by
Bcuz Deva Path
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Reviewer Chapter 0 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
29 views
7 pages
Reviewer Chapter 0
BSIT, INTEG
Uploaded by
Bcuz Deva Path
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Reviewer Chapter 0 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Reviewer Chapter 0 For Later
You are on page 1
/ 7
Search
Fullscreen
Chapter O: Linux Operating System Page + 1 backlink 0.1 Shell Commands Shell commands are used to instruct the linux system. To enter shell commands, we need to access the shell. For that, we can use a terminal such as the default one provided by the system. When a terminal starts up, the first thing you will see is the prompt which looks like this: user@host:~$ . This is where we enter our shell commands. The user is the current user logged into the system. The host is the name of system or the computer itself. Sometimes this is an ip address of a remote system. This is followed by a colon then the present working directory, which in our case is ~ (this symbol is called a tilde). Directory and folder means the same and may be used interchangeably. The prompt ends with the $ symbol where we can enter our commands. Sometimes we may see the #F symbol instead which means we are using the root user. 0.2 Displaying the Current Directory The present working directory is our current location in the filesystem. ~ means that we are in the currect user's home directory. For us to show our present working directory, we use the pwd command. For example: userthost:~$ pwd » /home/user The command pwd will display the present working directory: /home/user . The linux filesystem begins with the root folder / . In our working directory we are in the user folder inside the home folder of the root folder, each folder separated by the / symbol. Ina tree structure, it may look something like this: / F-— /home | fuser | “— other folders inside home L— other folders inside root0.3 Changing the Directory / Navigating the Filesystem Now, to navigate to other folders or locations in your filesystem you use the cd command which means change directory. This command takes one argument which is the path we want to navigate to. The path may be relative or absolute. Relative means our point of reference is the current directory while absolute means our point of reference is the root folder. Let's assume the folders we will be using already exists in the filesystem. Here is an example of a relative path: folder_name . When we pass this argument to the cd command, we will be navigated to a folder inside our currect directory. An example of an absolute path is /folder_name . When we pass this argument to the cd command, we will be navigated to a folder inside the root folder. For example: user@host:~$ cd folder_name user@host:~/folder_name$ pwd » /home/user/folder_name user¢host:~/folder_name$ cd /folder_name user@host: /folder_name$ pwd » /folder_name Notice that in the second prompt ~/folder_name is now shown after the cd command. We will see this kind of change whenever we change directory as we can see it also in the last prompt. For the sake of simplicity, we will be using only the $ symbol as our prompt for our next examples. There are also two other symbols we may use when using a relative path. These are the . andthe .. symbols. The . symbol is used to reference the current folder, so we may write either: cd foldex_name or cd ./folder_name . On the other hand, the .. symbol is used to reference the parent folder or the folder that contains the current folder. pwd /home/usex cd. pwd /home/user # no change, it's the current folder c pwd /home © pwd >/ Bereunre ee We can also use multiple instances of this symbol to navigate further up the filesystem such as: cd ../../.The / at the end is optional but it can give us a hint that we are navigating to a folder. Given this new insight, we can use this symbol to access folders or files from a parent directory. For example: $ pwd » /home/user $ cd ../../folder_name$ pwd » /folder_name In terms of absolute paths, we can also use two symbols: / and ~ as shorthands for the root and the current user's home folder respectively. For example: $ pwd > /home/user $d / $ pwd of $ cd ~ $ pnd >» /home/user $ cd /folder_name $ pwd » /folder_name $ cd ~/folder_name $ pnd » /home/user/folder_name 0.4 Listing Contents of a Directory Now that we know how to navigate our filesystem, let's start displaying contents of our directory. To list down the contents of a folder we use the 1s command. We can also use the dix command for this, but 1s is the preferred command. For example: $ pwd > /home/usex $1s > Desktop Documents Downloads $ dix » Desktop Documents Downloads The 1s or dix command will display folders we can navigate to or files we can open from the current directory. Both commands have options like -a or --all to not ignore entries that start with . suchas ., .., .cache, .config, etc. and many other options, but or now, we will stick with the basic commands. We can also pass an absolute or relative path as an argument to these commands to list down the contents of that path. For example: $ pwd > /home/user $s / > bin boot cdrom dev .. # folders inside root $1s > user # folders inside the parent folder: home0.5 Creating a Directory Now that we can see contents of a directory, let's create a folder. To create a folder, we use the mkdix command, i.e. make directory, and we need to provide a name as an argument. Multiple folders can also be created by passing all names separated by a single space. This means that in order to create a folder that has a space in its name, we must enclose the name in single or double quotation marks. For example: pwd /home/user mkdix demo cd demo pwd /home/usex/demo 1s # nothing is displayed because the folder is empty. mkdir folder1 folder? 1s folder1 folder2 mkdir ‘folder 3° mkdix “folder 4" ls folder1 folder2 ‘folder 3' ‘folder 4° VEER HHL erenure We can also use paths in our arguments. For example: pwd /home/user/demo mkdix folder1/folder5 ls foldert folder2 ‘folder 3' ‘folder 4° cd folder pwd /home/user/demo/foldert 1s folders mkdix ../foldex6 cd pwd /home/user/demo 1s folder1 folder2 ‘folder 3' ‘folder 4’ folderé VOL OHH ey earaere 0.6 Renaming a Folder / Moving a Folder Renaming and moving folder uses the same command my . This command takes two arguments, the source path and the target path. Both paths can use either absolute or relative paths.Let's first look at how we can use the command to rename a folder. Whether it's a folder or a file, renaming is like moving to the same location but with a different name. Here is an example: pwd /home/user 1s folder1 folder2 ‘folder 3' ‘folder 4' folder6 my ‘folder 3' folder3 1s folderl folder? folder3 ‘folder 4' folderé cd foldert pwd /home/user/folder1 my '../folder 4' ../foldera 1s folder1 folder2 folder3 folder4 folder YORL eur nnrare Now, let's look at how we can move our folders around the filesystem. Using the same command, we just need to specify the complete path of the target. For example: $ pwd /home/user/folder1 $1s > folders $ mv folders ../folders $1s > folderi folder2 folder3 folder4 folder6 In the above example, we can use the command my folder5 ../ where we only have to specify the target folder, just make sure to add the trailing slash. 0.7 Copying a Folder Copying a folder involves duplicating the contents of a directory to another location while retaining the original directory. Similar to moving or renaming a folder, the cp command is used for copying folders. This command takes two arguments, the source path and the destination path. Both paths can be specified using either absolute or relative paths. Let's delve into how we can use the cp command to copy a folder: $ pnd /home/user/ $ 1s > folder folder2 folder3 folder4 folder6 $ cp -r folder1 folder7 $1s > folder1 folder? folder3 folder4 folderé folder7cp -x folder? folder1/subfoldert ls folder1 subfoldert cp -r folder1 folder2/ 1s folder2 foldert The -x option is used to copy directories recursively, ensuring that all subdirectories and their contents are also copied. Remember to exercise caution when copying folders, especially when overwriting existing files or directories. 0.8 Removing a Folder In Linux, removing a folder is done using the xm command, which stands for "remove." This command removes directories and their contents recursively. However, it's essential to exercise caution when using the xm command as it permanently deletes files and folders, and they cannot be recovered easily. Here's how you can safely remove folders: $ pwd » /home/user/ ls folderl folder2 folder3 folder4 folder6 foldex7 am -x foldex7 1s folderi folder2 folder3 folder4 folder xm -r folder2/folder1 ls folder2 # nothing is displayed because the folder is empty. your oure If you only want to remove the contents of the folder, just use the wildcard * to match all contents inside the folder. If you want to remove multiple folders, separate each folder with spaces. pwd /home/user rm -r foldert/* 1s foldert # nothing is displayed because the folder is empty. 1s folder1 folder? folder3 folder4 foldex6 am -r folder foldexé Is folder1 folder2 folder3 your ernunre 0.9 Working with FilesIn addition to working with folders, Linux provides various commands for creating, copying, moving, renaming, and removing files. Understanding these commands is, essential for managing files efficiently. Let's explore each operation . To create an empty file, you can use the touch command followed by the file name. You can also create files simultaneously by specifying their names separated by spaces. 2. To copy a file, you can use the cp command followed by the source file and destination. Similar to folders, you can copy multiple files simultaneously by specifying their names separated by spaces. 3. To move a file, you can use the mv command followed by the source file and destination. Likewise, you can move multiple files simultaneously by specifying their names separated by spaces. 4, Renaming a file is similar to moving it to the same location with a different name. You can use the mv command for this. 5. To remove a file, you can use the xm command followed by the file name. Similarly, you can remove multiple files simultaneously by specifying their names separated by spaces. 6. You can also use wildcards like * to copy, move, or remove multiple files that match a pattern. pwd /hone/usex Is folder1 folder2 folder3 touch filel.txt file2.txt 1s filel.txt file2.txt folder1 folder2 folder3 cp filel.txt file2.txt foldert 1s foldert > filet.txt file2.txt ny filel.txt folder2 Is file2.txt folderl folder2 folder3 my file2.txt file.txt 1s file.txt folder folder2 folder3 xm foldex2/filet. txt 1s foldex2 # nothing is displayed because the folder is empty xm folder1/*.txt 1s foldert # nothing is displayed because the folder is empty Bee enrave YOOL ear eer ee Remember to exercise caution when working with files, especially when using commands like xm .
You might also like
Shell Navigation
PDF
No ratings yet
Shell Navigation
18 pages
Navigating The Linux File System: (Edwin Achimbi)
PDF
100% (2)
Navigating The Linux File System: (Edwin Achimbi)
4 pages
Linux Overview (Commands)
PDF
No ratings yet
Linux Overview (Commands)
9 pages
Commands
PDF
No ratings yet
Commands
11 pages
Part 1 Linux Chapter 2 File Systems
PDF
No ratings yet
Part 1 Linux Chapter 2 File Systems
44 pages
Introduction To UNIX Commands and Scripting: 0.0 Getting Help On-Line Manuals
PDF
No ratings yet
Introduction To UNIX Commands and Scripting: 0.0 Getting Help On-Line Manuals
18 pages
Lab 123
PDF
No ratings yet
Lab 123
30 pages
Practice Commands
PDF
No ratings yet
Practice Commands
151 pages
Basic Linux Commands
PDF
No ratings yet
Basic Linux Commands
19 pages
Directory Related Commands: Command Summary Use
PDF
No ratings yet
Directory Related Commands: Command Summary Use
18 pages
Os Lab Manual
PDF
No ratings yet
Os Lab Manual
66 pages
Introduction To Unix: Unit 2:the File System and Some File Handling Commands
PDF
No ratings yet
Introduction To Unix: Unit 2:the File System and Some File Handling Commands
62 pages
Linux Unit II
PDF
No ratings yet
Linux Unit II
70 pages
Linux
PDF
No ratings yet
Linux
18 pages
The Linux File System
PDF
No ratings yet
The Linux File System
10 pages
Basic Linux Commands Explained With Examples
PDF
No ratings yet
Basic Linux Commands Explained With Examples
10 pages
Lab 1
PDF
No ratings yet
Lab 1
13 pages
Ls - A - Ls .Newsrc
PDF
No ratings yet
Ls - A - Ls .Newsrc
3 pages
Lab No 03
PDF
No ratings yet
Lab No 03
13 pages
Lab 1
PDF
No ratings yet
Lab 1
6 pages
Unix Notes 2
PDF
No ratings yet
Unix Notes 2
13 pages
Linux Commands
PDF
No ratings yet
Linux Commands
13 pages
Lab Practice
PDF
No ratings yet
Lab Practice
13 pages
01 Unix Command Notes
PDF
No ratings yet
01 Unix Command Notes
6 pages
OSY Microproject
PDF
No ratings yet
OSY Microproject
12 pages
Linux - Part 1
PDF
No ratings yet
Linux - Part 1
43 pages
Linux Commands Full
PDF
No ratings yet
Linux Commands Full
24 pages
Linux Commands PDF
PDF
No ratings yet
Linux Commands PDF
14 pages
Directories and File Handling Commands
PDF
No ratings yet
Directories and File Handling Commands
10 pages
UNIX Tutorial One PDF
PDF
No ratings yet
UNIX Tutorial One PDF
47 pages
FileSyetmin Linux
PDF
No ratings yet
FileSyetmin Linux
28 pages
Schermafbeelding 2023-10-08 Om 16.21.07
PDF
No ratings yet
Schermafbeelding 2023-10-08 Om 16.21.07
66 pages
Unit-I Directory Commands 1. The PWD Command
PDF
100% (1)
Unit-I Directory Commands 1. The PWD Command
19 pages
Unix Commands
PDF
No ratings yet
Unix Commands
72 pages
Linux File System Notes
PDF
No ratings yet
Linux File System Notes
62 pages
Chapter 2 Linux File System
PDF
No ratings yet
Chapter 2 Linux File System
91 pages
Pen 100 Rebrand
PDF
No ratings yet
Pen 100 Rebrand
54 pages
Command Line
PDF
No ratings yet
Command Line
5 pages
Unix
PDF
No ratings yet
Unix
5 pages
Linux Commands
PDF
No ratings yet
Linux Commands
19 pages
Operating System Lab 2
PDF
No ratings yet
Operating System Lab 2
10 pages
P 1
PDF
No ratings yet
P 1
80 pages
Linux Filesystem Management
PDF
No ratings yet
Linux Filesystem Management
18 pages
Linux - Basic
PDF
No ratings yet
Linux - Basic
84 pages
UNIX Tutorial One
PDF
No ratings yet
UNIX Tutorial One
32 pages
OS Practical
PDF
No ratings yet
OS Practical
18 pages
AIM - TO Study Linux General Purpose Commands: Practical 2
PDF
No ratings yet
AIM - TO Study Linux General Purpose Commands: Practical 2
3 pages
03-Managing The Linux File System
PDF
No ratings yet
03-Managing The Linux File System
29 pages
UNIX Command
PDF
No ratings yet
UNIX Command
22 pages
OS Lab - Week 2
PDF
No ratings yet
OS Lab - Week 2
24 pages
Linux
PDF
No ratings yet
Linux
25 pages
Linux Cheatsheet
PDF
No ratings yet
Linux Cheatsheet
17 pages
Unix
PDF
No ratings yet
Unix
153 pages
Chapter 6 Lab - Working With Files and Directories
PDF
No ratings yet
Chapter 6 Lab - Working With Files and Directories
14 pages
LP Networking
PDF
No ratings yet
LP Networking
15 pages
Command Line Basics (Centos) : Shell Prompt
PDF
No ratings yet
Command Line Basics (Centos) : Shell Prompt
8 pages
ULI101 Week 2 Lecture Notes
PDF
No ratings yet
ULI101 Week 2 Lecture Notes
4 pages