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

Basic Shell Commands

This document provides a comprehensive overview of basic shell commands used in a command-line interface. It includes commands for listing files, changing directories, creating and removing files, copying, moving, viewing file contents, and searching for files, along with their options and examples. Each command is succinctly described to aid users in understanding their functionality and usage.

Uploaded by

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

Basic Shell Commands

This document provides a comprehensive overview of basic shell commands used in a command-line interface. It includes commands for listing files, changing directories, creating and removing files, copying, moving, viewing file contents, and searching for files, along with their options and examples. Each command is succinctly described to aid users in understanding their functionality and usage.

Uploaded by

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

Basic Shell Commands

Command Description Options Examples

• ls -l
• -l: Long format displays files and
listing. directories with detailed
• -a: Include information.
List files and hidden files • ls -a
ls
directories. hidden ones shows all files and
• -h: Human- directories, including
readable file • ls -lh
sizes. displays file sizes in a
human-readable format.

• cd /path/to/directory
changes the current
cd Change directory.
directory to the specified
path.

• pwd
Print current
pwd displays the current
working directory.
working directory.

• mkdir my_directory
Create a new
mkdir creates a new directory
directory.
named “my_directory”.

• rm file.txt
deletes the file named
“file.txt”.
• -r: Remove
• rm -r my_directory
directories
deletes the directory
Remove files and recursively.
rm “my_directory” and its
directories. • -f: Force removal
contents.
without
• rm -f file.txt
confirmation.
forcefully deletes the file
“file.txt” without
confirmation.

• cp -r directory
destination
copies the directory
• -r: Copy “directory” and its contents
Copy files and
cp directories to the specified
directories.
recursively. destination.
• cp file.txt destination
copies the file “file.txt” to
the specified destination.
Basic Shell Commands

Command Description Options Examples

• mv file.txt new_name.txt
renames the file “file.txt” to
Move/rename files “new_name.txt”.
mv
and directories. • mv file.txt directory
moves the file “file.txt” to
the specified directory.

Create an empty • touch file.txt


touch file or update file creates an empty file
timestamps. named “file.txt”.

• cat file.txt
View the contents
cat displays the contents of
of a file.
the file “file.txt”.

• head file.txt
shows the first 10 lines of
• -n: Specify the
Display the first the file “file.txt”.
head number of lines
few lines of a file. • head -n 5 file.txt
to display.
displays the first 5 lines of
the file “file.txt”.

• tail file.txt
shows the last 10 lines of
• -n: Specify the
Display the last the file “file.txt”.
tail number of lines
few lines of a file. • tail -n 5 file.txt
to display.
displays the last 5 lines of
the file “file.txt”.

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

• find /path/to/search -
• -name: Search by
name “*.txt”
Search for files filename.
find searches for all files with
and directories. • -type: Search by
the extension “.txt” in the
file type.
specified directory.

You might also like