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

Linux commands and shortcut

The document provides a comprehensive overview of Linux commands, covering various topics such as file and directory operations, process management, networking, and user management. It includes command descriptions, options, and examples for practical usage. Additionally, it highlights the graphical interface of UNIX systems and essential shortcut commands for efficient navigation and editing.

Uploaded by

jeraldave4
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Linux commands and shortcut

The document provides a comprehensive overview of Linux commands, covering various topics such as file and directory operations, process management, networking, and user management. It includes command descriptions, options, and examples for practical usage. Additionally, it highlights the graphical interface of UNIX systems and essential shortcut commands for efficient navigation and editing.

Uploaded by

jeraldave4
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

<Lesson>

Commands and Group 2


Agustin, John Marvin
Bantilan, Jerald

Shortcut Keys Casio, John Darwin


Cantago, Arianne
Dichos, Kent

of Linux Gabinete, Loraine


<Lesson> GABINETE

{01}Linux Interface
 Users commonly interact with a UNIX system via a text-based
command-line interface.
 In a terminal, commands are entered at a prompt and results
are displayed.
 UNIX systems also provide a graphical interface similar to
those of the Macintosh and Windows platforms.
<Lesson>

The Graphical interface under UNIX consist


of several layers:

Hardware Layer Desktop Manager Windows Manager

This is the physical hardware, like The desktop environment sits on The window manager controls the
the monitor, graphics card, mouse, top of the X Window System and appearance and behavior of
and keyboard, which the graphical window manager. It provides a windows. It allows users to move,
interface interacts with. more integrated user experience, resize, and close windows.
complete with file managers, Examples include Openbox,
icons, panels, and other user- Compiz, and Mutter. Users can
friendly tools. Popular desktop replace the window manager
environments in UNIX include without changing the entire
GNOME, KDE Plasma, and XFCE. graphical interface.
<Lesson>

The Graphical interface under UNIX consist


of several layers:

Operating System
Applications X-Windows (Kernel)

These are the graphical programs The X Window System provides The kernel controls hardware
that users interact with, such as the foundation for graphical interactions and provides low-level
web browsers, text editors, and environments in UNIX. It manages access to system resources. It
media players, all running within windows, handles user input ensures the graphical interface can
the framework provided by the (keyboard and mouse), and communicate with hardware like
layers beneath them. provides network transparency, the display and input devices
meaning it can display programs
running on remote systems.
<Lesson>

0 The Terminal
 You need a terminal window, which runs a program called a

2 shell
 Open a terminal window from the “Applications” menu,
under “Activities” or by searching for “Terminal”.

 The terminal window on your desktop should contain some


characters that look something like:

[username@lisp ~]$

this called the prompt.


<Lesson>

0 The Terminal
 The prompt gives you information about the account and

2 machine being used and the current directory you’re in.


 The prompt indicates that UNIX is waiting for (or
“prompting”) you to type something. Whenever you type
something after a UNIX prompt, UNIX tries to understand it
as a command.

Note: Commands and filenames in UNIX are case


sensitive. Spaces are required between commands,
arguments, and options. The basic template for a UNIX
command is command-name [options] [argument1]
[argument2] ...
<Lesson>

LINUX
COMMAND
<Lesson>

File and Directory Operations Commands


Command Description Options Examples
ls List files and directories -l – Long format listing ls-l – displays files and directories with
-a – Include hidden files hidden ones. detailes information.
-h – Human-readable file sizes. ls-a – Shows all files and directories.
ls-lh – displays file sizes in a human
readable format.

cd Change directory cd/path/to/directory – Changes the


current directory to the specified path
pwd Print current working directory pwd – displays the current working
directory.
mkdir Create a new directory mkdir my_directory – Creates a new
directory named “my_directory”
rm Remove files and directories -r – Remove directories recursively rm file.txt – Deletes the file named
-f – Force removal without confirmation. “file.txt”
rm –r my_directory – deletes the
directory “my_directory” ans its
contents.
rm –f file.txt – forcefully deletes the file
“file.txt” without confirmation.
<Lesson>

File and Directory Operations Commands


Command Description Options Examples
cp Copy files and directories -r – Copy directories recursively cp –r directory destination – Copies the
directory and its contents to the
specified destination.
cp file.txt destination - copies the fie
“file.txt” to the specified destination

mv Move/ rename files and directories mv file.txt new_name.txt - Renames the


file “file.txt” to “new_name.txt”
mv file.txt directory - Moves the file
“file.txt” to the specified directory.

touch Create an empty file or update file touch file.txt – Creates an empty file
timestamps named “file.txt”
cat View the contents of a file cat file.txt – displays the contents of the
file “file.txt”.
head Displays the first few lines of a file -n – Specify the number of lines to head file.txt – shows the first 20 lines of
display the file.
Head –n 5 file.txt- displays the first 5
lines of the file.
<Lesson>

File and Directory Operations Commands


Command Description Options Examples
Tail Display the last few lines of a file -n – specif the number of lines to display tail file.txt – shows the last 10 lines of
the file.
tail –n 5 file.txt – displays the last 5 lines
of the file.

ln Create links between files -s – creates symbolic (soft) links. ln –s source_file link_name – creates a
symbolic link named “link_name”
pointing to “source_file”

find Search for files and directories -name – serach by file name find/path/to/search-name”*.txt” –
-type – search by file type Searches for all files with the extension
“.txt” in the specified directory.
<Lesson>

File Permission Commands


Command Description Options Examples
cphmod Change file permissions u – User/owner permissions. chmod u+rwx fiel.txt – grants read, write
g - Group permissions and execute permissions to the owner of
o – other permissions the file.
+ - Add permissions
- -remove permissions
= - set permissions explicitly

chown Change file owneshp chown user file.txt – Changes the owner
of “file.txt” to the specified user.
chgrp Change group ownership chgrp group file.txt – changes the group
ownership of “file.txt” to the specified
group.
umask Set default file permissions umask 022- sets the default file
permissions to read and write for the
owner and read-only for group and
other.
<Lesson> AGUSTIN

File Compression and Archiving Commands


Command Description Options Examples
tar Create or extract archive files -c – Create new archive. tar –czvf archive.tar.gz files/ - creates a
-x – Extract files from an archive. compressed tar archive named
-f – Specify the archive file name “archived.tar.gz” containing the files in
-v – Verbose mode the “files/” directory.
-z – Compress the archive with gxip
-j- compress the archive with bzip2.

gzip Compress files. -d – Decompress files gzip file.txt – compresses the file
“file.txt” and renames it as “file.txt.gz”.
zip Creatw compressed zip archives -r – recursively include directories zip archive.zip file1.txt file2.txt – creates
zip archive named
“archive.zip”containing “file1.txt” and
“file2.txt”.
<Lesson>

Process Management
Command
Commands
Description Options Examples
ps Display running processes -aux – Show all rocesses ps aux – shows all running processes
with detailed information.
top Monitor system processes in real – time. top – displays a dynamic view of system
processes and their resource usage.
kill Terminate a process -9 – forcefully kill a process kill PID – Terminates the process with the
specified process ID
pkill Terminates processes based on their pkill process_name – terminates all
name processes with the specified name.
pgrep List processes based on their name pgrep process_name – list all processes
with the specified name
<Lesson>

Process
CommandManagement
DescriptionCommandsOptions Examples
grep Used to search for specific patterns -i: Ignore case distinctions while grep -i “hello” file.txt
or regular expressions in text files or searching. grep -v “error” file.txt
streams and display matching lines. -v: Invert the match, displaying non- grep -r “pattern” directory/
matching lines. grep -l “keyword” file.txt
-r or -R: Recursively search directories for grep -n “pattern” file.txt
matching patterns. In these examples we are extracting our
-l: Print only the names of files desired output from filename (file.txt)
containing matches.
n: Display line numbers alongside
matching lines.
-w: Match whole words only, rather than
partial matches.
-c: Count the number of matching lines
instead of displaying them.
-e: Specify multiple patterns to search
for.
-A: Display lines after the matching line.
-B: Display lines before the matching line.
-C: Display lines both before and after
the matching line.
<Lesson>

System Information Commands


Command Description Options Examples
uname Print system information. -a: All system information uname -a
displays all system information
whoami Display current username. whoami
shows the current username.

df Show disk space usage -h: Human-readable sizes. df -h


displays disk space usage in a human-
readable format.

du Estimate file and directory sizes. -h: Human-readable sizes. du -sh directory/
-s: Display total size only. provides the total size of the specified
directory.

free Display memory usage information. -h: Human-readable sizes. free -h


displays memory usage in a human-
readable format.
<Lesson>

System Information Commands


Command Description Options Examples
uptime Show system uptime. uptime
shows the current system uptime.

lscpu Display CPU information. lscpu


provides detailed CPU information.

lspci List PCI devices. lspci


List PCI devices.

lsusb List USB devices. lsusb


lists all connected USB devices.
<Lesson> CASIO

Networking
Command
CommandsDescription Examples

ifconfig Display network interface ifconfig


information. shows the details of all network
interfaces.

pingi Send ICMP echo requests to a host. ping google.com


sends ICMP echo requests to
“google.com” to check connectivity.

netstat Display network connections and netstat -tuln


statistics. shows all listening TCP and UDP
connections.

ss Display network socket information ss -tuln


shows all listening TCP and UDP
connections.
ssh Securely connect to a remote server. ssh user@hostname
initiates an SSH connection to the
specified hostname.
<Lesson>

Networking Commands
Command Description Examples
scp Securely copy files between hosts. scp file.txt
user@hostname:/path/to/destination
securely copies “file.txt” to the specified
remote host.

wget Download files from the web. wget http://example.com/file.txt


downloads “file.txt” from the specified
URL.

curl Transfer data to or from a server. curl http://example.com


retrieves the content of a webpage from
the specified URL.
<Lesson>

IO Redirection Commands
Command Description
Cmd < file Input of cmd is taken from file
cmd > file Standard output (stdout) of cmd is redirected to
file.
Cmd 2> file stderr is redirected to the same place as stdout.
cmd1 <(cmd2) Output of cmd2 is used as the input file for cmd1.
cmd > /dev/null Discards the stdout of cmd by sending it to the
null device.
cmd &> file Every output of cmd is redirected to file.
cmd 1>&2 stdout is redirected to the same place as stderr.
cmd >> file Appends the stdout of cmd to file.
<Lesson>

Environment Variable Commands


Command Description
export VARIABLE_NAME=value Sets the value of an environment variable.
echo $VARIABLE_NAME Displays the value of a specific environment
variable.
Env Lists all environment variables currently set in the
system.
unset VARIABLE_NAME Unsets or removes an environment variable.
export –p
Shows a list of all currently exported environment
variables.
env VAR1=value COMMAND Sets the value of an environment variable for a
specific command.
Printenv
Displays the values of all environment variables.
<Lesson>

User Management Commands


Command Description

Who Show who is currently logged in.

sudo adduser username Create a new user account on the system with the specified
username.
Finger Display information about all the users currently logged into
the system, including their usernames, login time, and
terminal.
sudo deluser USER GROUPNAME Remove the specified user from the specified group.

Last Show the recent login history of users.


finger username Provide information about the specified user, including their
Provide information about the specified user, including their
username, real name, terminal, idle time, and login time.
sudo userdel -r username Delete the specified user account from the system, including
their home directory and associated files. The -r option
ensures the removal of the user’s files.
<Lesson>

User Management Commands


Command Description

sudo passwd -l username Lock the password of the specified user


account, preventing the user from logging
in.
su – username Switch to another user account with the
user’s environment.
sudo usermod -a -G GROUPNAME Add an existing user to the specified group.
USERNAME The user is added to the group without
removing them from their current groups.
passwd User change the password
<Lesson> BANTILAN

Shorcut Commands
Bash Shortcut Commands
Navigation Description

Ctrl + A Move to the beginning of the line.


Ctrl + E Move to the end of the line.
Ctrl + B Move back one character.
Ctrl + F Move forward one character.
Alt + B Move back one word
Alt + F Move forward one word.
<Lesson>

Bash Shortcuts Commands


Editing Description

Ctrl + U Cut/delete from the cursor position to


the beginning of the line.
Ctrl + K Cut/delete from the cursor position to
the end of the line.
Ctrl + W Cut/delete the word before the
cursor.
Ctrl + Y Paste the last cut text
Ctrl + L Clear the screen.
<Lesson>

Bash Shortcuts Commands


History Description

Ctrl + R Search command history (reverse


search).
Ctrl + G Escape from history search mode.
Ctrl + P Go to the previous command in
history.
Ctrl + N Go to the next command in history.
Ctrl + C Terminate the current command.
<Lesson>

Nano Shortcuts Commands


File Operations Description

Ctrl + O Save the file.


Ctrl + X Exit Nano (prompt to save if
modified).
Ctrl + R Read a file into the current buffer.
Ctrl + J Justify the current paragraph
<Lesson>

Nano Shortcuts Commands


Navigation Description

Ctrl + Y Scroll up one page.


Ctrl + V Scroll down one page.
Alt + \ Go to a specific line number.
Alt + , Go to the beginning of the current
line.
Alt + . Go to the end of the current line
<Lesson>

Nano Shortcuts Commands


Editing Description

Ctrl + K Cut/delete from the cursor position to


the end of the line.
Ctrl + U Uncut/restore the last cut text.
Ctrl + 6 Mark a block of text for copying or
cutting.
Alt + 6 Copy the marked block of text.
Alt + K Cut/delete the marked block of text.
<Lesson> DICHOS

Nano Shortcuts Commands


Search and Replace Description

Ctrl + W Search for a string in the text.


Alt + W Search and replace a string in the
text.
Alt + R Repeat the last search.
<Lesson>

VI Shortcuts Commands
Command Description

Cw Change the current word. Deletes from the cursor position to


the end of the current word and switches to insert mode.
Dd Delete the current line.

X Delete the character under the cursor.

R Enter replace mode. Overwrites characters starting from the


cursor position until you press the Escape key.
O Insert a new line below the current line and switch to insert
mode.
U Undo the last change.

S Substitute the character under the cursor and switch to


insert mode.
Dw Delete from the cursor position to the beginning of the next
word.
D Delete from the cursor position to the end of the line.
<Lesson>

VI Shortcuts Commands
Command Description

4dw Delete the next four words from the cursor position.

A Switch to insert mode at the end of the current line.

S Delete the current line and switch to insert mode.

R Replace the character under the cursor with a new character


entered from the keyboard
I Switch to insert mode before the cursor.

3dd Delete the current line and the two lines below it.

ESC Exit from insert or command-line mode and return to


command mode.
U Restore the current line to its original state before any
changes were made.
~ Switch the case of the character under the cursor.

a Switch to insert mode after the cursor.

C Delete from the cursor position to the end of the line and
switch to insert mode.
<Lesson>

Vim Shortcuts Commands


Normal Description

I Enter insert mode at the current


cursor position.
X Delete the character under the cursor.
dd Delete the current line
Yy Copy the current line
P Paste the copied or deleted text
below the current line.
U Undo the last change.
Ctrl + R Redo the last undo.
<Lesson>

Vim Shortcuts Commands


Command Mode Description Visual Mode Description
:w Save the file V

Enter visual mode to select text.

:q Quit Vim. Y Copy the selected text.

:q! Quit Vim without saving changes. D Delete the selected text.

:wq Save and quit Vim. P Paste the copied or deleted text
or
:x:x

:s/old/new/g Replace all occurrences of “old”


with “new” in the file.

:set nu
or
:set numbe Display line numbers.
<Lesson>

Thank You!

You might also like