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

Some linux commands (1)

The document provides an overview of commonly used Linux commands, their format, and examples of usage. It also includes keyboard shortcuts for efficient command-line navigation and operations. Key commands discussed include cp for copying files, ls for listing directory contents, mv for moving/renaming files, and mkdir for creating directories.
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)
10 views

Some linux commands (1)

The document provides an overview of commonly used Linux commands, their format, and examples of usage. It also includes keyboard shortcuts for efficient command-line navigation and operations. Key commands discussed include cp for copying files, ls for listing directory contents, mv for moving/renaming files, and mkdir for creating directories.
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/ 5

Some commonly used Linux commands:-

Commands
Commands are just programs elsewhere on the computer and entering their name
on the command-line runs them.
Commands have a predicable format:
command -flags target
 The command is the name of the program to run,
 the (optional) flags modify its behaviour and
 the target is what the command is to operate on, ie name of a file or
directory
Keyboard short-cuts:
Keyboard short-cuts are defined for most common operations.
A few of these are listed below.
The most useful is the tab key to complete command names and paths in the file-
system, referred to a 'tab-completion'. Pressing tab once will complete a path up to
the first ambiguity encountered and pressing again gives a list of possible
completions (you can type the next letter or so of the one you want and press tab
again to attempt further auto-completion).
Control-a Move to beginning of line
Control-e Move to end of line
Alt-f Move forward one word
Alt-b Move backwards one word
Control-l Clear screen, leaving current line
Tab Try to automatically complete path

cp Command
CoPy file – copy a file from place to another
Examples:
• cp file1 file2 # copy file1 to file2
• cp file1 directory/ # copy file1 into directory.
The copy of the file has path directory/file1
• cp file1 file2 directory/ # copy file1 and file2 to directory.
When copying multiple files, the destination must be a path to a directory.
ls command
LiSt contents of directory
Examples:
• ls # List files
• ls -a # Also show hidden files (those whose name begins with a
period).
• ls -l # Show more information about each file (permissions, owner,
group, time and date of last modification).

mv Command
MoVe file – move (rename) a file. Usage is exactly like cp except that the file is
moved rather than copied.
Examples:
• mv file1 file2 # Rename file1 to file2
• mv file1 directory/ # Move file to directory
• mv file1 file2 directory/ # Move files to directory

mkdir command
MaKe DIRectory – create a new directory
Examples:
• mkdir path # Make directory described by path
• mkdir -p directory1/directory2 # Make the directory described and all directories
leading to it (its Parents) if necessary.
Command Description
Lists all files and directories in the present
ls
working directory
ls - R Lists files in sub-directories as well
ls - a Lists hidden files as well
Lists files and directories with detailed
ls - al
information like permissions, size, owner, etc.
cat > filename Creates a new file
cat filename Displays the file content
Joins two files (file1, file2) and stores the output
cat file1 file2 > file3
in a new file (file3)
mv file "new file path" Moves the files to the new location
mv filename new_file_name Renames the file to a new filename
Allows regular users to run programs with the
sudo
security privileges of the superuser or root
rm filename Deletes a file
man Gives help information on a command
Gives a list of all past commands typed in the
history
current terminal session
clear Clears the terminal
Creates a new directory in the present working
mkdir directoryname
directory or a at the specified path
rmdir Deletes a directory
mv Renames a directory

You might also like