Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

BASIC LINUX COMMANDS

COMMAND DESCRIPTION
pwd Print Working Directory shows you the location
where you are.
Pwd –L Prints symbolic paths if one exists.
Pwd –P Prints out actual path without any symbolic links
Ls Lists all files and directories in the present
location
Ls –R Lists files in subdirectories as well
Ls –a Lists hidden files also
Ls –la Lists files and directories with detailed file
information
Ls –d Includes hidden directories
Ls –t Sorts by date and time
Cd [Directory/Path] Change directory – run alone will navigate you to
home directory
Cd ~ Also takes you to home directory
Cd / Takes you to root directory
Cd .. Moves up one directory
Mkdir [directoryname] Makes a directory
Touch [filename] Creates a blank file
Touch [file1, file2, Creates multiple blank files
file3]
Touch –a [filename] Changes access time
Touch –c [filename] Checks if the file exists before creating it
Touch –YYMMDDHHMM Changes file creation time to the specified time
[filename]
Cat [filename] Shows the content of a file
Cat Listens for input and echoes it to the output
stream
Cat > [newfile] Echoes input into the file
Cp [file1] [newfile1] Copies a file to a new name
Cp [Path/To/File] Copies a file from one directory to another
[New/Path/Dir]
Cp –r [directory] Copies a directory and all files inside
[newdirectory]
Mv [filename] Renames a file (moves it)
[newfilename]
Mv -I [filename] Renames a file – confirms overwrites before
[newfilename] performing
Mv –f [file1] [newfile] Forces overwrites
Mv –b [file1] [newfile] Makes a backup of the file before moving
Rm [file] Deletes a file
Rm [Path/To/Filename] Deletes a file at another location
Rm *.[file ending] Deletes files with certain endings
Rm -I Confirms deletion before performing
Rm –r [DirectoryName] Deletes a directory and all subfolders and files
Head [filename] Shows the top 10 lines of a file
Head –n [number] Shows the first specified number of lines of a
[filename] file
Tail [filename] Shows the last 10 lines of a file
Tail –n [number] Shows the last specified number of lines of a file
[filename]
Tail –n [number] + Shows the last number of lines of a file after a
[number] [file] specified number
Tail –f [file] Shows the end of a file in live view
More [filename] Prints of the contents of a file 53 lines at a
time
Less –N [filename] Shows number lines with them

You might also like