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

Module 3 - Linux Cli - LFCP

This document provides an overview of basic Linux command line interface (CLI) commands and their functionalities, focusing on the bash shell. Key commands discussed include pwd, cd, ls, cat, mkdir, cp, mv, rm, and others, along with their usage and options. The document also highlights helpful commands like help, man, whatis, and file for further assistance and information in the Linux environment.

Uploaded by

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

Module 3 - Linux Cli - LFCP

This document provides an overview of basic Linux command line interface (CLI) commands and their functionalities, focusing on the bash shell. Key commands discussed include pwd, cd, ls, cat, mkdir, cp, mv, rm, and others, along with their usage and options. The document also highlights helpful commands like help, man, whatis, and file for further assistance and information in the Linux environment.

Uploaded by

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

10/2/2024

Module 3
Linux CLI
Thu Ya

The Shell
• The shell is basically a program that takes your commands from the
keyboard and sends them to the operating system to perform. If
you’ve ever used a GUI, you’ve probably seen programs such as
“Terminal” or “Console” these are just programs that launch a shell
for you.
• In this course we will use the shell program bash (Bourne Again shell),
almost all Linux distributions will default to the bash shell. There are
other shells available such as ksh, zsh, tsch, but we won’t get into any
of those.

The Shell

1
10/2/2024

pwd (Print Working Directory)


• Everything in Linux is a file, as you journey deeper into Linux you’ll
understand this, but for now just keep that in mind. Every file is
organized in a hierarchical directory tree. The first directory in the
filesystem is aptly named the root directory. The root directory has
many folders and files which you can store more folders and files, etc.

cd (Change Directory)

ls (List Directories)
• How do we figure out what is available to us? Right now it’s like we
are moving around in the dark. Well, we can use the wonderful ls
command to list directory contents. The ls command will list
directories and files in the current directory by default, however you
can specify which path you want to list the directories of.

2
10/2/2024

cat
• We’re almost done navigating files, but first let’s learn how to read a
file. A simple command to use is the cat command, short for
concatenate, it not only displays file contents but it can combine
multiple files and show you the output of them.
• It’s not great for viewing large files and it’s only meant for short
content. There are many other tools that we use to view larger text
files that we’ll discuss in the next lesson.

history
• In your shell, there is a history of the commands that you previously
entered, you can actually look through these commands. This is quite
useful when you want to find and run a command you used
previously without actually typing it again.
• Want to run the previous command without typing it again? Use !!. If
you typed cat file1 and want to run it again, you can actually just go !!
and it will run the last command you ran.

Tab
• While we are talking about useful things, one of the most useful
features in any command-line environment is tab completion. If you
start typing the beginning of a command, file, directory, etc and hit
the Tab key, it will autocomplete based on what it finds in the
directory you are searching as long as you don’t have any other files
that start with those letters. For example if you were trying to run the
command chrome, you can type chr and press Tab and it will
autocomplete chrome.

3
10/2/2024

mkdir (Make Directory)


• We’re gonna need some directories to store all these files we’ve been
working on. The mkdir command (Make Directory) is useful for that, it
will create a directory if it doesn’t already exist. You can even make
multiple directories at the same time.

cp (Copy)
• Let’s start making some copies of these files. Much like copy and
pasting files in other operating systems, the shell gives us an even
simpler way of doing that.
• You can copy multiple files and directories as well as use wildcards. A
wildcard is a character that can be substituted for a pattern based
selection, giving you more flexibility with searches. You can use
wildcards in every command for more flexibility.
• $ cp *.txt /home/maung/documents

cp (Copy a directory)
• Try to do a cp on a directory that contains a couple of files to your
Documents directory. Didn’t work did it? Well that’s because you’ll
need to copy over the files and directories inside as well with -r
command.
• $ cp -r Pumpkin/ /home/pete/Documents

4
10/2/2024

mv (Move)
• Used for moving files and also renaming them. Quite similar to the cp
command in terms of flags and functionality.

rm (Remove)
• To remove files you can use the rm command. The rm (remove)
command is used to delete files and directories.
• $ rm file1
• $ rm -r directory1

help
• Linux has some great built-in tools to help you how to use a
command or check what flags are available for a command. One tool,
help, is a built-in bash command that provides help for other bash
commands (echo, logout, pwd, etc).
• $ help echo

5
10/2/2024

man
• Manual of cli programs
• Man pages are manuals that are by default built into most Linux
operating systems. They provide documentation about commands
and other aspects of the system.
• Try it out on a few commands to get more information about them.

• $ man ls

whatis
• Whew, we’ve learned quite a bit of commands so far, if you are ever
feeling doubtful about what a command does, you can use the whatis
command. The whatis command provides a brief description of
command line programs.

• $ whatis cat

• The description gets sourced from the manual page of each


command. If you ran whatis cat, you’d see there is a small blurb with
a short description.

less
• If you are viewing text files larger than a simple output, less is more. (There is
actually a command called more that does something similar, so this is ironic.)
The text is displayed in a paged manner, so you can navigate through a text file
page by page.
• Use the following command to navigate through less:
• q - Used to quit out of less and go back to your shell.
• Page up, Page down, Up and Down - Navigate using the arrow keys and page keys.
• g - Moves to beginning of the text file.
• G - Moves to the end of the text file.
• /search - You can search for specific text inside the text document. Prefacing the
words you want to search with /
• h - If you need a little help about how to use less while you’re in less, use help.

6
10/2/2024

Nano or vim
• Text editor

file
• In Linux, did you notice that the filename didn’t conform to standard
naming like you’ve probably seen with other operating systems like
Windows? Normally you would expect a file called banana.jpeg and
expect a JPEG picture file.
• In Linux, filenames aren’t required to represent the contents of the
file. You can create a file called funny.gif that isn’t actually a GIF.
• To find out what kind of file a file is, you can use the file command. It
will show you a description of the file’s contents.

exit
• To exit from the shell, you can use the exit command

7
10/2/2024

Other useful command


• ifconfig or ip - Display network configuration.
• Ip a – display IP addresses.
• hostname - Display or set the system hostname.
• shutdown - Shutdown or restart the system.
• ls -l - List files in long format.
• ls -a - List all files, including hidden ones.
• users - Display currently logged-in users.
• Ping – ping network command
• Date – display the date

You might also like