SlideShare a Scribd company logo
linux chapter 5.pptx lesson About introduction to linux
1 2
Unit 5: Getting to Know the Command Line
Topics
1. Command Line Skills
2. Getting help commands
3. Working with files and Directories
1 3
1. Command Line Skills
A) Command Line Interface (CLI)
The Command Line Interface (CLI), is a text-based interface to the computer, where
the user types in a command and the computer then executes it. The CLI
environment is provided by an application on the computer known as a terminal.
Accessing a Terminal
• There are many ways to access a terminal window. Some systems will boot
directly to a terminal.
• there are commonly two ways to access a terminal, a GUI-based terminal and a
virtual terminal( press on Crl+Alt+F1 to return GUI press on Crl+Alt+F7
1 4
B) Prompt
• The prompt is designed to tell the user to enter a command.
• The structure of the prompt may vary between distributions, but will typically contain information about the
user and the system. Below is a common prompt structure:
sysadmin@localhost:~$
Systadmin : username
Local host: computer name
~ : current directory
$ : user type or Normal user .
C) Shell
• A shell is the interpreter that translates commands entered by a user into actions to be performed by the
operating system.
• The most commonly used shell for Linux distributions is called the BASH shell.
• The BASH shell also has other popular features:
1.Scripting: The ability to place commands in a file and execute the file, resulting in all of the commands being
executed. This feature also has some programming features, such as conditional statements and the ability to
create functions (AKA, subroutines).
2.Aliases: The ability to create short "nicknames" for longer commands.
3.Variables: Variables are used to store information for the BASH shell.
1 5
D) Formatting commands
The typical format for a command is as follows:
command [options] [arguments] example : ls –l .d
Working with Options
• Options can be used with commands to expand or modify the way a command behaves.
• For example, you can use the -l option with the ls command to display more information about
the files that are listed. The ls -l command will list the files contained within the current
directory .
E) Command history
• When you execute a command in a terminal, the command is stored in a "history list". To view
the history list of a terminal, use the history command:
• sysadmin@localhost:~$ history or history –c
F) Introducing BASH shell variables
A BASH shell variable is a feature that allows you or the shell to store data.
To display the value of a variable, you can use the echo command. The echo command is used to
display output in the terminal; in the example below, the command will display the value of the
HISTSIZE variable: sysadmin@localhost:~$ HISTSIZE =500
1 6
2. Getting Help commands
A) man Pages
Provides the a basic description of the purpose of the command, example : man ls
B) info Command/ learning guide and links
provides documentation on operating system commands and features.
example : info cal
C) --help
Provide basic information about command for example : find --help .
D) which Command/display the full path to the command in question:
searches for the location of a command by searching the PATH variable.
For example : which ls
E) type Command
The type command can be used to determine information about various commands.
Example : type which
F) whereis command. /specifically find commands and man pages.
search for the location of a command . Example : whereis date
1 7
3.Working with Files and Directories
A) Introduction
When working in a Linux Operating System, you will need to know how to manipulate
files and directories. Some Linux distributions have GUI-based applications that allow you
to manage files, but it is important to know how to perform these operations via the
command line.
B) Understanding Files and Directories
Files are used to store data such as text, graphics , programs and devices.
Directories "folders") are used to provide a hierarchical organization structure.
This directory structure is called the filesystem by most Linux users.
To view the root filesystem, type ls /:
1 8
C) Directory Path
A path allows you to specify the exact location of a directory. For the sound directory, the path
would be /etc/sound.
There are two types of paths : Absolute path and Relative Path .
Absolute path :
With an absolute path, you always provide directions to a directory starting from the root
directory. For example :cd /home/rooble/Desktop/arday.
Relative Path :
With relative path, provides directions using your current location .
For example : cd arday .
D) Directory and file listing commands
• Home Directory
Provides system users and represent it ~ ( tilde ) ex : cd ~
• Current Directory
is the directory where you are currently working in a terminal. To determine current directory
use pwd command .
1 9
Changing Directories
If you want to change to a different directory, use the cd (change directory)
command. Cd Desktop .
Listing Files in a Directory
• The ls command (ls is short for list) can be used to display the contents of a
directory.
• Listing Colors
• There are many different types of files in Linux:
• Listing Hidden Files
To display all files, including hidden files, use the -a option to the ls command. Ls -a
Type Description
plain file A file that isn't a special file type; also called a normal file
directory A directory file (contains other files)
executable A file that can be run like a program
symbolic link A file that points to another file
1 10
• Long Display Listing
There is information about each file example : ls –l
• Human Readable Sizes
When you display file sizes with the -l option to the ls command, you end up with
file sizes in bytes. For text files, a byte is 1 character. For example : ls -1h
• Listing Directories
When the command ls -d is used, it refers to the current directory. ls -d
1 11
E) manipulating Directories
1. Creating directory
syntax : $mkdir dir name example :$kdir science
2. Create multiple directories :
Syntax :$mkdir dir1 dir2 dir3 example :$mkdir math economic
3. Entering the directory
syntax :$cd dirname example :$ cd science
4. Copy directory
Syntax :$ cp-r dir dir2 example :$cp science copy science
5. Renaming directory
Syntax :$mv dir1 dir2 example : $mv science cilmi
6. Deleting directory
syntax: $rmdir dirname- empty directory example :$rmdir science
Syntax : $rm-r dirname – is not empty example :$rm-r science
1 12
F) Manipulating files
1.Creating file
Syntax : $cat>filename example : $cat>cashar.txt
Syntax : $touch filename –empty file example : $touch cashar2.txt
2. Appending contents to the file
Syntax : $cat>>filename example : $cat>>cashar2.txt
3.Concatenating multiple files :
Syntax : $cat file1 file2 >file3 example : $cat cashar.txt cashar2.txt >cashar3
4.Displaying the file content /open file
Syntax : $cat filename example : $cat cashar.txt
5.Renaming the file
Syntax : $mv filename example : $mv cashar.txt tijaabo.txt
6.Copying the file
Syntax : $cp source destination example : $cp cashar.txt copycashar.txt
1 13
Cont …
7. Viewing the file type
Syntax : $ file filename example : $ file cashar.txt
8. Viewing the whole file
Syntax : $cat filename example : $cat cashar.txt or
Syntax : $less filename –one page example : $less cashar.txt
9. Viewing parts of a file
A- head command – first lines of the file
Syntax : $ head -3 filename example : $ head-3 cashar.txt
B-tail command – last lines of the file
Syntax : $ tail -3 filename example : $ last -3 cashar.txt
10. Deleting the file
Syntax : $ rm file example : $ rm cashar.txt
Syntax : $ rm file1 file 2 file example : $ rm cashar.txt cashar2.txt
Ad

More Related Content

Similar to linux chapter 5.pptx lesson About introduction to linux (20)

Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
Sreenatha Reddy K R
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OS
Mohamed Abdallah
 
basic-unix.pdf
basic-unix.pdfbasic-unix.pdf
basic-unix.pdf
OmprakashNath2
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
UNIX.pptx
UNIX.pptxUNIX.pptx
UNIX.pptx
P S Rani
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
sbmguys
 
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEMTERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
pssafvan97
 
QSpiders - Unix Operating Systems and Commands
QSpiders - Unix Operating Systems  and CommandsQSpiders - Unix Operating Systems  and Commands
QSpiders - Unix Operating Systems and Commands
Qspiders - Software Testing Training Institute
 
Basic Commands-part1.pptx
Basic Commands-part1.pptxBasic Commands-part1.pptx
Basic Commands-part1.pptx
GOGOMASTER2
 
SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1
solgenomics
 
Introduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examplesIntroduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examples
Noé Fernández-Pozo
 
Using Unix
Using UnixUsing Unix
Using Unix
Dr.Ravi
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
Priyadarshini648418
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
Teja Bheemanapally
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic Commands
Shankar Mahure
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
iman darabi
 
Introduction to LINUX
Introduction to LINUXIntroduction to LINUX
Introduction to LINUX
AVI DHALL
 
Linux commands
Linux commandsLinux commands
Linux commands
penetration Tester
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritping
chockit88
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
Sreenatha Reddy K R
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OS
Mohamed Abdallah
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
sbmguys
 
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEMTERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
pssafvan97
 
Basic Commands-part1.pptx
Basic Commands-part1.pptxBasic Commands-part1.pptx
Basic Commands-part1.pptx
GOGOMASTER2
 
SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1
solgenomics
 
Introduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examplesIntroduction to UNIX Command-Lines with examples
Introduction to UNIX Command-Lines with examples
Noé Fernández-Pozo
 
Using Unix
Using UnixUsing Unix
Using Unix
Dr.Ravi
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
Priyadarshini648418
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic Commands
Shankar Mahure
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
iman darabi
 
Introduction to LINUX
Introduction to LINUXIntroduction to LINUX
Introduction to LINUX
AVI DHALL
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritping
chockit88
 

Recently uploaded (20)

Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Ad

linux chapter 5.pptx lesson About introduction to linux

  • 2. 1 2 Unit 5: Getting to Know the Command Line Topics 1. Command Line Skills 2. Getting help commands 3. Working with files and Directories
  • 3. 1 3 1. Command Line Skills A) Command Line Interface (CLI) The Command Line Interface (CLI), is a text-based interface to the computer, where the user types in a command and the computer then executes it. The CLI environment is provided by an application on the computer known as a terminal. Accessing a Terminal • There are many ways to access a terminal window. Some systems will boot directly to a terminal. • there are commonly two ways to access a terminal, a GUI-based terminal and a virtual terminal( press on Crl+Alt+F1 to return GUI press on Crl+Alt+F7
  • 4. 1 4 B) Prompt • The prompt is designed to tell the user to enter a command. • The structure of the prompt may vary between distributions, but will typically contain information about the user and the system. Below is a common prompt structure: sysadmin@localhost:~$ Systadmin : username Local host: computer name ~ : current directory $ : user type or Normal user . C) Shell • A shell is the interpreter that translates commands entered by a user into actions to be performed by the operating system. • The most commonly used shell for Linux distributions is called the BASH shell. • The BASH shell also has other popular features: 1.Scripting: The ability to place commands in a file and execute the file, resulting in all of the commands being executed. This feature also has some programming features, such as conditional statements and the ability to create functions (AKA, subroutines). 2.Aliases: The ability to create short "nicknames" for longer commands. 3.Variables: Variables are used to store information for the BASH shell.
  • 5. 1 5 D) Formatting commands The typical format for a command is as follows: command [options] [arguments] example : ls –l .d Working with Options • Options can be used with commands to expand or modify the way a command behaves. • For example, you can use the -l option with the ls command to display more information about the files that are listed. The ls -l command will list the files contained within the current directory . E) Command history • When you execute a command in a terminal, the command is stored in a "history list". To view the history list of a terminal, use the history command: • sysadmin@localhost:~$ history or history –c F) Introducing BASH shell variables A BASH shell variable is a feature that allows you or the shell to store data. To display the value of a variable, you can use the echo command. The echo command is used to display output in the terminal; in the example below, the command will display the value of the HISTSIZE variable: sysadmin@localhost:~$ HISTSIZE =500
  • 6. 1 6 2. Getting Help commands A) man Pages Provides the a basic description of the purpose of the command, example : man ls B) info Command/ learning guide and links provides documentation on operating system commands and features. example : info cal C) --help Provide basic information about command for example : find --help . D) which Command/display the full path to the command in question: searches for the location of a command by searching the PATH variable. For example : which ls E) type Command The type command can be used to determine information about various commands. Example : type which F) whereis command. /specifically find commands and man pages. search for the location of a command . Example : whereis date
  • 7. 1 7 3.Working with Files and Directories A) Introduction When working in a Linux Operating System, you will need to know how to manipulate files and directories. Some Linux distributions have GUI-based applications that allow you to manage files, but it is important to know how to perform these operations via the command line. B) Understanding Files and Directories Files are used to store data such as text, graphics , programs and devices. Directories "folders") are used to provide a hierarchical organization structure. This directory structure is called the filesystem by most Linux users. To view the root filesystem, type ls /:
  • 8. 1 8 C) Directory Path A path allows you to specify the exact location of a directory. For the sound directory, the path would be /etc/sound. There are two types of paths : Absolute path and Relative Path . Absolute path : With an absolute path, you always provide directions to a directory starting from the root directory. For example :cd /home/rooble/Desktop/arday. Relative Path : With relative path, provides directions using your current location . For example : cd arday . D) Directory and file listing commands • Home Directory Provides system users and represent it ~ ( tilde ) ex : cd ~ • Current Directory is the directory where you are currently working in a terminal. To determine current directory use pwd command .
  • 9. 1 9 Changing Directories If you want to change to a different directory, use the cd (change directory) command. Cd Desktop . Listing Files in a Directory • The ls command (ls is short for list) can be used to display the contents of a directory. • Listing Colors • There are many different types of files in Linux: • Listing Hidden Files To display all files, including hidden files, use the -a option to the ls command. Ls -a Type Description plain file A file that isn't a special file type; also called a normal file directory A directory file (contains other files) executable A file that can be run like a program symbolic link A file that points to another file
  • 10. 1 10 • Long Display Listing There is information about each file example : ls –l • Human Readable Sizes When you display file sizes with the -l option to the ls command, you end up with file sizes in bytes. For text files, a byte is 1 character. For example : ls -1h • Listing Directories When the command ls -d is used, it refers to the current directory. ls -d
  • 11. 1 11 E) manipulating Directories 1. Creating directory syntax : $mkdir dir name example :$kdir science 2. Create multiple directories : Syntax :$mkdir dir1 dir2 dir3 example :$mkdir math economic 3. Entering the directory syntax :$cd dirname example :$ cd science 4. Copy directory Syntax :$ cp-r dir dir2 example :$cp science copy science 5. Renaming directory Syntax :$mv dir1 dir2 example : $mv science cilmi 6. Deleting directory syntax: $rmdir dirname- empty directory example :$rmdir science Syntax : $rm-r dirname – is not empty example :$rm-r science
  • 12. 1 12 F) Manipulating files 1.Creating file Syntax : $cat>filename example : $cat>cashar.txt Syntax : $touch filename –empty file example : $touch cashar2.txt 2. Appending contents to the file Syntax : $cat>>filename example : $cat>>cashar2.txt 3.Concatenating multiple files : Syntax : $cat file1 file2 >file3 example : $cat cashar.txt cashar2.txt >cashar3 4.Displaying the file content /open file Syntax : $cat filename example : $cat cashar.txt 5.Renaming the file Syntax : $mv filename example : $mv cashar.txt tijaabo.txt 6.Copying the file Syntax : $cp source destination example : $cp cashar.txt copycashar.txt
  • 13. 1 13 Cont … 7. Viewing the file type Syntax : $ file filename example : $ file cashar.txt 8. Viewing the whole file Syntax : $cat filename example : $cat cashar.txt or Syntax : $less filename –one page example : $less cashar.txt 9. Viewing parts of a file A- head command – first lines of the file Syntax : $ head -3 filename example : $ head-3 cashar.txt B-tail command – last lines of the file Syntax : $ tail -3 filename example : $ last -3 cashar.txt 10. Deleting the file Syntax : $ rm file example : $ rm cashar.txt Syntax : $ rm file1 file 2 file example : $ rm cashar.txt cashar2.txt
  翻译: