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

Linux Command Line Cheat Sheet: Is Command For Listing Files

Uploaded by

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

Linux Command Line Cheat Sheet: Is Command For Listing Files

Uploaded by

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

Page 1 of 5 CheatSheet (Uresearcher)

Linux Command Line Cheat Sheet


-l (small L letter): long listing format

ls -g Print entries without owner


Is Command for Listing Files ls -lX Sort the list by extension [long information
listing format]

ls *k Search files ending with the


ls ~ List files in the home directory
letter ‘k’ (for example)
ls -X Sort the list by extension
ls List files in the current working
directory ls seq* Search files with characters ‘seq’
ls -li Print the index number (or inode (for example) in the beginning
ls ../ List parent directory number) of each file

ls -lh Check the size of files and


List the contents of the directory directoriesin a human-readable
ls ../../ one level above format Linux Directory Structure
ls -a List all files including hidden files
starting with ‘.’. / The root directory
ls -lhS Sort file size (largest file size first)
[long listing format]
/bin Essential user binaries
ls -l The long listing of the content (programs). Important system
of the current directory programs and utilities are
ls -p Add / (slash sign) to mark
ocated in /bin
directory
ls -d */ List directory entries only
Contains the files needed to
/boot
ls -F Add / (slash sign) to mark boot the system
ls -r Reverse order while sorting directory and * sign to indicate
executable files
ls -R /media The standard location for
List subdirectories recursively temporary media
ls -m Print out all directories and files [subdirectories within /media]
ls -lt Sort the list by modification
separated by a comma.
time (newest first) [long listing
format] /dev Contains a number of special
files that represent devices
Print out all directories and files
Sort the list by modification time ls -Q in the directory with quotation
ls -t
(newest first) marks. /etc Contains configuration files

Take Linux Certification for Drug Discovery or Linux Certification for Scientific Research: https://uresearcher.com/courses
Page 2 of 5 CheatSheet (Uresearcher)

Linux Command Line Cheat Sheet


/home Contains a home folder for /usr Contains applications and files rm -rf Forcefully and recursively
each user used by users [read-only in directory deletes a directory along
normal operation] with its content
$ rm -rf Uresearcher
/lib Contains libraries needed by /var Contains applications and files
the essential binaries used by users [writable] rm Forcefully deletes a file
filename $ rm -f cheatsheet.pdf

Contains recovered files rm -f Forcefully deletes a file


/lost+
found [important when file system Directory operations filename $ rm -f cheatsheet.pdf
crashes]

displays the present working


/mnt Temporary mount points pwd directory Change Directory (cd)

mkdir Create a new directory. cd Change from the current working


/opt Contains subdirectories for directory to the home directory
optional software packages $ mkdir Uresearcher

cd Change from the current working


mkdir -p Create nested directories.
/proc contains special files that directory directory to a specified directory
$ mkdir -p Uresearcher
represent system and $ cd Uresearcher
/hello/researcher
process information
cd - Change from the current working
directory to the previous working
/root The home directory of the root
Be careful while performing delete directory
user operations
cd .. Change Current directory to parent
directory
/run A standard place to store Remove/delete an existing
rmdir
transient files directory [provided it is empty] Move one directory lower from the
cd ../
$ rmdir Uresearcher current working directory
/sbin System administration binaries
cd 'dir Navigate to directories with
rm -r Deletes a directory recursively name space in their names $ cd
directory along with its content with dir\ name\ with\ space
/tmp Contains temporary files
$ rm -r Uresearcher space'

Take Linux Certification for Drug Discovery or Linux Certification for Scientific Research: https://uresearcher.com/courses
Page 3 of 5 CheatSheet (Uresearcher)

Linux Command Line Cheat Sheet


Search and Locate Files and find Find and remove a single file grep -Rnw
directory
To know the exact line
.-type f $ find . -type f -name where the string of text
Directories -name "cheatsheet.pdf" -exec -e “string” exist $ grep-Rnw ~/
"filename rm -f {} \; Uresearcher/ -e
find . Find files using the name .ext" “cheatsheet”
-name [Case-sensitive] in the current -exec rm
filename directory -f {} \;
$ find . -name uresearcher.txt grep -Rnw Search string in a special
--include type of file (for example: pdf)
=\*.sh $ grep -Rnw --include=\*.pdf
find /home Find files using the name find directory ~/Uresearcher/ -e “cheatsheet”
. -type f Find and remove multiple
-name [Case-sensitive] available files $ find . -type f -name -e “string”
filename under the home directory -name
"*.ext" "*.pdf" -exec rm -f {} \;
$ find /home -name
-exec grep Search for more than one
uresearcher.txt
rm -f {} \; -Rnw string patterns
--include $ grep -Rnw --include=\*.pdf
=\*.sh ~/Uresearcher/ -e
ind . Find files using the name
directory “cheatsheet” -e “linux”
-iname and ignoring the case find /tmp To find all empty files under -e
filenam $ find . - iname cheatsheet.pdf -type a certain path “string1”
f -empty -e
find / - Find all directories with “string2”
type d - directory name in / directory
name $ find / -type d - name find /tmp To file all empty directories
directory Uresearcher -type d under a certain path. Handling compressed archive
-empty files (create, extract, view
find . -type Find all files with name modify archive files)
f -name and extension in a current
filename. working directory Find a Specific String or Word
ext $ find . -type f -name
cheatsheet.pdf
in Files and Directories tar Create a tar archive file (e.g.
-cvf name uresearcher.tar) from a
_of directory (~/Uresearcher/)
find Find all files in a directory grep -Rw Recursively and aggressively _compressed $ tar -cvf uresearcher.tar
. -type with a certain extension directory search a directory (e.g. ~/ _file.tar to ~/Uresearcher/
f -name (e.g. PDF) $ find . -type f -e “string” Uresearcher/) for a string _be
"*.ext" -name "*.pdf" “cheatsheet”.$ grep -Rw ~/ _compressed
Uresearcher/ -e “cheatsheet” _directory/

Take Linux Certification for Drug Discovery or Linux Certification for Scientific Research: https://uresearcher.com/courses
Page 4 of 5 CheatSheet (Uresearcher)

Linux Command Line Cheat Sheet


tar cvzf Create a gzip archive file tar -tvf List content of tar archive
name_of (e.g. uresearcher.tar) from compressed file in Linux $ tar -tvf
_compressed a directory (~/Uresearcher/) _file uresearcher.tar
_file $ tar cvzf uresearcher.tar.gz Note: -tvf is common
.tar ~/Uresearcher/ option for listing content
to_be_com- OR of all formats (e.g. tar, tar
pressed_ $ tar cvzf uresearcher.tgz .gz, tgz, tar.bz2, tar.tbz, tar
directory/ ~/Uresearcher/ .tb2) Note: Group of files can be extracted
using the same way and wildcards
tar -xvf Untar a single file from (e.g. extract all pdf files)
tar cvfj Create a bz2 archive file
compressed tar file in Linux
to_be_ (e.g. uresearcher.tar)
compressed from a directory
_file $ tar -xvf uresearcher.tar $ tar -jxvf uresearcher.tar.gz “*.pdf”
filename cheatsheet.pdf
_file.tar to (~/Uresearcher/)
_be_
compressed $ tar cvfj uresearcher
_directory/ .tar.bz2 ~/Uresearcher/
OR tar -zxvf Untar a single file from
$ tar cvfj uresearcher. compressed tar.gz file in Linux
tar.tbz ~/Uresearcher/ _file filename $ tar -zxvf uresearcher
.tar.gz cheatsheet.pdf
OR
$ tar cvfj uresearcher
tar -rvf Append new files/
.tar.tb2 ~/Uresearcher/ tar -jxvf Untar a single file from compressed directories to the already
compressed tar.bz2 file in Linux _file filename compressed file
_file $ tar -jxvf uresearcher $ tar -rvf uresearcher.tar
tar -xvf To untar or extract a tar file filename .tar.gz cheatsheet.pdf newcheatsheet.pdf
compressed $ tar -xvf uresearcher .tar Note: This command
_file Note: For untaring cannot be used for an
multiple files from any of existing tar.gz or tar.bz2
tar -xvf To untar or extract a tar these file formats, use files
compressed file $ tar -xvf uresearcher their respective option
_file -C .tar-C ~/newdata (e.g. -xvf, -zxvf, -jxvf)
specified and “file1 “file 2”
_directory Note: -xvf is common tar -czf Check the size of the tar,
option for extracting all $ tar -jxvf uresearcher.tar compressed tar.gz, and tar.bz2 archive file
formats (e.g. tar, tar.gz, .gz “cheatsheet.pdf” _file | wc -c $ tar -czf uresearcher
tgz, tar.bz2, tar.tbz, tar.tb2) “cheatsheet.txt” .tar | wc -c

Take Linux Certification for Drug Discovery or Linux Certification for Scientific Research: https://uresearcher.com/courses
Page 5 of 5 CheatSheet (Uresearcher)

Linux Command Line Cheat Sheet


Split and Join commands for split -n10 Split files with a specified number of
Note: To run an executable,
managing large files file.txt chunks $ split -n10 file.txt first do chmod +x and then run
Output: xaa xab xac xad xae xaf xag the sh script.sh command
split file.txt Split a large file (e.g. 5000 lines) xah xai xaj $ chmod +x multicommands.sh
into smaller files (by default 1000
lines) split -n10 -e Split files with a specified number sh script.sh To execute the commands and
$ split file.txt &> output. log the output/error to a file
file.txt of chunks with no zero size chunk
Output: xaa xab xac xad xae log $ sh multicommands.sh &>
$ split -n10 -e file.txt
output.log]
Output: xaa xab xac xad xae xaf
split -a4 file. Change the default suffix length
txt of 2 to user-specified xag xah xai xaj sh -x script. To execute the commands and
$ split -a4 file.txt sh &> output. log each command as it is
Output: xaaaaa xaaaab xaaaac log executed
xaaaad xaaaae cat To concatenate two (or more files) $ sh -x multicommands.sh &>
file1.txt output.log
file2.txt >
and write the output to a new file
split -b2000 Split a larger file (e.g. 10000 bytes) $ cat file1.txt file2.txt > newfile.txt
new- sh -e To execute the commands and
file.txt into smaller files (e.g. 2000 bytes) file.txt script.sh abort on encountering an error
by size &> $ sh -e multicommands.sh &>
$ split -b2000 file.txt output.log output.log
join To join two (or more files) and write
file1.txt the output to a new file
split -b Split a larger file into smaller files
file2.txt > $ join file1.txt file2.txt > newfile.txt About Uresearcher:
20M file.txt by size in MB (e.g. 20 MB each)
new-
file.txt Uresearcher is a research education company.
$ split -b 20M file.txt
Our mission is to provide a cutting-edge
research curriculum, high-quality teaching,
and 24×7 scientific support accessible to
split -d file. Split files with a numeric suffix To execute multiple commands anyone, at any time, anywhere in the world.
txt $ split -d4 file.txt
Output: x00 x01 x02 x03 x04
at once with a text file This cheat sheet is made available under the
Research Education for Everyone
initiative.
split -500 file. Split files with a specified number sh script.sh To execute multiple commands at
once with each command written in Know more: https://uresearcher.com/
txt of lines $ split -500 file.txt a new line (sequential ordering) in
Output: xaa xab xac xad xae xaf the text file (e.g. multicommands.sh) Copyright©Uresearcher Growth Labs
$ sh multicommands.sh Published on: 20th September 2021
xag xah xai xaj

Take Linux Certification for Drug Discovery or Linux Certification for Scientific Research: https://uresearcher.com/courses

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy