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

Linux Commands

The document discusses 13 common Linux commands: pwd, ls, cd, mkdir, rmdir, chmod, cat, cp, mv, rm, grep, head, and tail. It provides descriptions and examples of how to use each command in the Linux terminal.

Uploaded by

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

Linux Commands

The document discusses 13 common Linux commands: pwd, ls, cd, mkdir, rmdir, chmod, cat, cp, mv, rm, grep, head, and tail. It provides descriptions and examples of how to use each command in the Linux terminal.

Uploaded by

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

Linux commands

1. pwd
pwd stands for Print Work directory and does exactly what you think – it shows
the directory you’re currently in. This is one of the handiest Linux terminal
commands that aims to make new user’s life peaceful by ensuring they don’t get
lost in that seemingly cryptic terminal window.

2. ls
The ls command is probably one of the most widely used commands. It presents
to you the contents of a particular directory – both files and directories.

▪ ls –lh list directory content and its permissions

▪ ls –a list hidden files

3. cd
Short for Change Directory, the cd command is behind your movement from one
directory to another.

▪ cd /home/Cristiana (using path directory)


▪ cd ~ // , “ ~ ” stands for the user’s home directory
▪ cd / - navigates to the top directory
▪ cd dirname - moves to the directory identified
▪ cd .. - one directory above

4. mkdir
Want to create a new folder through the terminal? The mkdir command is created
for just this specific purpose. It lets you create folders anywhere you like in your
Linux system – given you have got the necessary permission, of course!

• mkdir dirname

5. rmdir
rmdir command allows you to delete specific folders from your system without
any hassles.

• rmdir dirname

6. chmod
The chmod command is among the most powerful Linux commands you will use
to change or modify the access permissions of system files or objects. This
command can take a very diverse set of parameters from users and, based on
those changes, the file permission.

▪ chmod 777 dirname (or path) - everyone can access


▪ chmod 700 dirname (or path) – only the creator can access

7. cat
Designed initially for concatenating multiple files, the cat command is used for
numerous other purposes since. This is among other Linux commands you will
use to create new files, view file contents in the terminal, and redirect output to
another command-line tool or file.

➢ Create new text file (*Ctrl+D to save and exit file): cat > newfile.txt
➢ Display text file on screen, read text file: cat filename, cat /path/to/file
➢ Modify file - to append (add data to existing) data to a file test.txt: cat >>
test.txt

➢ Display content of multiple files: cat filename1.txt filename2.txt


➢ Content of test file will be appended to the test1 file: cat test.txt>>test1.txt
➢ Standard output of the file to new or existing (it will override test1.txt if
exist!): cat test.txt>test1.txt
➢ Set line number: cat –n filename.txt

8. cp
The cp command is just a short way of telling your machine to copy a file or
directory from one folder to another. It is among other de-facto Linux commands
you can’t live without.

9. mv
Short for a move, just like cp, you can use the mv command to move either
single or multiple files from one location to another.

➢ Move a file: mv file path_destination


➢ Renaming a file: mv old_file new_file

10. rm

rm stands for 'remove' as the name suggests rm command is used to delete or remove
files and directory in UNIX like operating system. If you are new to Linux then you
should be very careful while running rm command because once you delete the files
then you can not recover the contents of files and directory:

▪ rm filename.txt OR
▪ rm filename1.tx filename2.txt

11. grep
Grep command is among the most powerful regular expression terminal
commands you can use when searching for patterns inside large volumes of text
files. It will take the pattern you’re looking for as input and search the specified
files for that particular pattern.
Grep pattern file(s) = globally search for a regular expression and print all lines
containing it

➢ -v: print all lines that do not match patter


➢ -n: print the matched line and its line number
➢ -l : print only the names of files with matching lines
➢ -c: print only the count of matching lines
➢ -I : match either upper or lowercase

12. head
The head command allows you to view the beginning of a file or piped data
directly from the terminal. It’s one of the most widely used Linux commands by
users who works heavily with text processing. Use this command whenever you
are going through a lot of files in the terminal to increase your productivity.

head -n <number of lines> <file1> <file2> <file3>

13. tail
A compliment to the previous command, chances are you will use the tail
command much more than the header commands:

tail -n <number of lines> <file1> <file2> <file3>

You might also like