0% found this document useful (0 votes)
16 views

The Linux Command Line

The Linux Command Line

Uploaded by

Darren Siow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

The Linux Command Line

The Linux Command Line

Uploaded by

Darren Siow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

The Linux Command

Line
Reasons to learn Linux Command
Line
1. More control
a) Cmd gives more control over machine than GUI
b) Cmd allows you to perform tasks that are not possible/practical with GUI, e.g. starting up servers,
managing processes, dealing with hidden files, changing permissions, interact with databases.
c) Cmd offers direct line into the core of your machine, offering more power and flexibility

2. Faster speed
a) Cmd can be faster than GUI, as typing is generally faster than clicking

3. Allows automation
a) Cmd allows you to automate tasks, making it easy to do repetitive tasks or schedule them to happen
at a specific time
Topics
1. Command Line Basics
2. Getting Help using Man
3. Navigation
4. Creating Files and Folders
5. Using Nano
6. Deleting, Copying, Moving
7. Shortcuts and History
8. Working with Files
9. Redirection
10. Piping
11. Expansion
12. Finding things (including grep)
13. Understanding and changing Permissions
14. The Environment
15. Writing our own commands
16. Cron
1. Command Line Basics
a) The Prompt
• Blinking cursor means waiting for user input
b) Keyboard arrow keys
• Cycle through command history
c) Command Line structure
• Command (verb) + Options (adjective) + Option Parameters + Arguments (object)
d) Arguments
e) Options

Option points to note Examples Remarks


Long form date --universal Not every option has a long form (most don’t)
Short form date –u
Combining options ncal -3 –h, ncal -3h Combining options with a single dash is more succinct
Options with parameters ncal –A3 It is common practice to put options before arguments
2a. Accessing and Navigating the
Manual
1. Access manual
• Type “man” followed by command name
2. Navigate manual
• Use arrow keys to scroll up and down
• Press spacebar to go to the next page
• Press B to go to the previous page
3. Exit manual
• Type “q” and press Enter
4. Search manual
• Type “/” followed by pattern you are searching for
3. Navigation
1. Root Directory
1. Denoted by /
2. Home Directory
1. Difference with Root: ??
3. The pwd command
1. Print Working Directory  Tells you where you are
4. The ls command
1. Lists out stuff in a directory; comes with a few options (ls –a, ls –l)
5. The cd command
1. Change to other directories
2. Option to use relative or absolute paths when changing directories
3. Navigation
Topic Description Example
Root Directory • Starting point for the file system; the top folder
• Actual directory name is “/”
• Confusingly, there is a sub-directory named root
Home Directory • Stores each user’s data, files and personal directories /home/Colt
• A sub-directory of root /home/Kitty
• Common folders in home include Desktop, Documents,
Downloads, Music, Public
• Shortcut to home is “~” tilde
The pwd command • A.k.a “Where am I” command /home/colt/Desktop
• Prints the path of your current working directory, starting
from root “/”
• pwd is often used in scripts to log or verify the current
directory before performing operations.
3. Navigation
Topic Description Example
The ls command • Lists the contents of a directory • Basic command: ls
• Running ls without arguments lists • Advanced command: ls [option] [path]
the files and folders in the current • ls –la /home/colt -> lists all files
working directory (including hidden ones) in long format in
• Visual indicators: files and folders the /home/colt directory
are usually coloured differently
• You can use either relative or
absolute paths as arguments for ls
The cd command • Change directory – allows you to • cd directory_name
navigate between directories in the • cd ..  move up to parent directory
file system • cd ../../  move up two levels
• Tab completion – start typing the • cd ~  return to home directory
directory name and press tab to
autocomplete
3. Navigation mindmap
Prints out
Home
Absolute directory
path ~
pwd Relative
path
Begins with

Can be used in Root


Parent
directory
directory
/
..
cd ls

Current
directory
.
4. Creating Files & Folders Mindmap
touch File1 File2 File3 mkdir folder1 folder2

syntax touch mkdir mkdir path/folder

touch path/file
Use cases mkdir -p
grandparent/parent/child
Quickly create Pre-create files
placeholder that will be
files for testing populated by • Ensures Directory Structure
or scripting other programs • No errors thrown if some or all
directories already exist
5. Nano Editor
• Nano is built inside the terminal – so you don’t have to leave the
terminal while changing your file
• Nano is more beginner friendly than Vim and Emacs.
• Nano includes search, spellcheck, syntax highlighting, etc.
5. Nano Editor
Action Command Example
To open a file with Nano Nano filename Nano shopping_list.txt
Navigating in Nano Use arrow keys
Entering input in Nano Start typing to edit the file directly
Saving changes

You might also like