SlideShare a Scribd company logo
40 Basic Linux Command-line Tips and Tricks
1. Everything in Linux is a file including the hardware and even the directories.
2. # : Denotes the super(root) user
3. $ : Denotes the normal user
4. /root: Denotes the super user’s directory
/home: Denotes the normal user’s directory.
5. Switching between Terminals
§ Ctrl + Alt + F1-F6: Console login
§ Ctrl + Alt + F7: GUI login
6. The Magic Tab: Instead of typing the whole filename if the unique pattern for a particular file is given
then the remaining characters need not be typed and can be obtained automatically using the Tab button.
7. ~(Tilde): Denotes the current user’s home directory
8. Ctrl + Z: To stop a command that is working interactively without terminating it.
9. Ctrl + C: To stop a command that is not responding. (Cancellation).
10. Ctrl + D: To send the EOF( End of File) signal to a command normally when you see ‘>’.
11. Ctrl + W: To erase the text you have entered a word at a time.
12. Up arrow key: To redisplay the last executed command. The Down arrow key can be used to print
the next command used after using the Up arrow key previously.
13. The history command can be cleared using a simple option –c (clear).
14. cd : The cd command can be used trickily in the following ways:
cd : To switch to the home user
cd * : To change directory to the first file in the directory (only if the first file is a directory)
cd .. : To move back a folder
cd - : To return to the last directory you were in
15. Files starting with a dot (.) are a hidden file.
16. To view hidden files: ls -a
17. ls: The ls command can be use trickily in the following ways:
ls -lR : To view a long list of all the files (which includes directories) and their subdirectories recursively .
ls *.* : To view a list of all the files with extensions only.
18. ls -ll: Gives a long list in the following format
drwxr-xr-x 2 root root 4096 2010-04-29 05:17 bin where
drwxr-xr-x : permission where d stands for directory, rwx stands for owner privilege, r-x stands for the
group privilege and r-x stands for others permission respectively.
Here r stands for read, w for write and x for executable.
2=> link count
root=>owner
root=>group
4096=> directory size
2010-04-29=>date of creation
05:17=> time of creation
bin=>directory file(in blue)
The color code of the files is as follows:
Blue: Directory file
White: Normal file
Green: Executable file
Yellow: Device file
Magenta: Picture file
Cyan: link file
Red: Compressed file
File Symbol
-(Hyphen) : Normal file
d=directory
l=link file
b=Block device file
c=character device file
19. Using the rm command: When used without any option the rm command deletes the file or directory
( option -rf) without any warning. A simple mistake like rm / somedir instead of rm /somedir can cause
major chaos and delete the entire content of the /(root) directory. Hence it is always advisable to use rm
command with the -i(which prompts before removal) option. Also there is no undelete option in Linux.
20. Copying hidden files: cp .* (copies hidden files only to a new destination)
21. dpkg -l : To get a list of all the installed packages.
23. Use of ‘ > ‘ and ‘ >> ‘ : The ‘ > ‘ symbol ( input redirector sign) can be used to add content to a file
when used with the cat command. Whereas ‘ >> ‘ can be used to append to a file. If the ‘ >> ‘ symbol is
not used and content is added to a file using only the ‘>’ symbol the previous content of the file is deleted
and replaced with the new content.
e.g: $ touch text (creates an empty file)
$ cat >text
This is text’s text. ( Save the changes to the file using Ctrl +D)
$cat >> text
This is a new text. (Ctrl + D)
Output of the file:
This is text’s text.
This is a new text.
23. To count the number of users logged in : who |wc –l
24. cat: The cat command can be used to trickly in the following way:
- To count no. of lines from a file : cat <filename> |wc -l
- To count no. of words from a file : cat <filename> |wc -w
- To count no. of characters from a file : cat <filename> |wc –c
25. To search a term that returns a pattern: cat <filename> |grep [pattern]
26. The ‘tr’ command: Used to translate the characters of a file.
tr ‘a-z’ ‘A-Z’ <text >text1 : The command for example is used to translate all the characters from lower
case to upper case of the ‘text’ file and save the changes to a new file ‘text1′.
27. File permission using chmod: ‘chmod’ can be used directly to change the file permission of files in
a simple way by giving the permission for root, user and others in a numeric form where the numeric
value are as follows:
r(read-only)=>4
w(write)=>2
x(executable)=>1
e.g. chmod 754 text will change the ownership of owner to read, write and executable, that of group to
read and executable and that of others to read only of the text file.
28. more: It is a filter for paging through text one screenful at a time.
Use it with any of the commands after the pipe symbol to increase readability.
e.g. ls -ll |more
29. cron : Daemon to execute scheduled commands. Cron enables users to schedule jobs (commands
or shell scripts) to run periodically at certain times or dates.
1 * * * * echo “hi” >/dev/tty1 displays the text “hi” after every 1 minute in tty1
.—————- minute (0 – 59)
| .————- hour (0 – 23)
| | .———- day of month (1 – 31)
| | | .——- month (1 – 12) OR jan,feb,mar,apr …
| | | | .—– day of week (0 – 7) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
* * * * * command to be executed
Source of example: Wikipedia
30. fsck: Used for file system checking. On a non-journaling file system the fsck command can take a
very long time to complete. Using it with the option -c displays a progress bar which doesn’t increase the
speed but lets you know how long you still have to wait for the process to complete.
e.g. fsck -C
31. To find the path of the command: which command
e.g. which clear
32. Setting up alias: Enables a replacement of a word with another string. It is mainly used for
abbreviating a system command, or for adding default arguments to a regularly used command
e.g. alias cls=’clear’ => For buffer alias of clear
33. The du (disk usage) command can be used with the option -h to print the space occupied in human
readable form. More specifically it can be used with the summation option (-s).
e.g. du -sh /home summarizes the total disk usage by the home directory in human readable form.
34. Two or more commands can be combined with the && operator. However the succeeding command
is executed if and only if the previous one is true.
e.g. ls && date lists the contents of the directory first and then gives the system date.
35. Surfing the net in text only mode from the terminal: elinks [URL]
e.g: elinks www.google.com
Note that the elinks package has to be installed in the system.
36. The ps command displays a great more deal of information than the kill command does.
37. To extract a no. of lines from a file:
e.g head -n 4 abc.c is used to extract the first 4 lines of the file abc.c
e.g tail -n 4 abc.c is used to extract the last 4 lines of the file abc.c
38. Any changes to a file might cause loss of important data unknowingly. Hence Linux creates a file
with the same name followed by ~ (Tilde) sign without the recent changes. This comes in really handy
when playing with the configuration files as some sort of a backup is created.
39. A variable can be defined with an ‘=’ operator. Now a long block of text can be assigned to the
variable and brought into use repeatedly by just typing the variable name preceded by a $ sign instead of
writing the whole chunk of text again and again.
e.g ldir=/home/my/Desktop/abc
cp abcd $ldir copies the file abcd to /home/my/Desktop/abc.
40. To find all the files in your home directory modified or created today:
e.g. find ~ -type f -mtime 0
http://www.yolinux.com/TUTORIALS/LinuxTutorialSysAdmin.html

More Related Content

What's hot

Important Linux Commands
Important Linux CommandsImportant Linux Commands
Important Linux Commands
Arun Sharma
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformatics
Bonnie Ng
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
Hanan Nmr
 
Basic Linux commands
Basic Linux commandsBasic Linux commands
Basic Linux commands
atozknowledge .com
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
Raghav Arora
 
BASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUXBASIC COMMANDS OF LINUX
Linux commands
Linux commandsLinux commands
Linux commands
bhatvijetha
 
Linux commd
Linux commdLinux commd
Linux commd
ragav03
 
Linux commd
Linux commdLinux commd
Linux commd
ragav03
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
Noé Fernández-Pozo
 
Linux commands part -2
Linux commands part -2Linux commands part -2
Linux commands part -2
bhatvijetha
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
shanmuga rajan
 
One Page Linux Manual
One Page Linux ManualOne Page Linux Manual
One Page Linux Manualdummy
 
Basics of unix
Basics of unixBasics of unix
Basics of unix
Deepak Singhal
 
Top 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsTop 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu Commands
Yusuf Felly
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
 

What's hot (18)

Important Linux Commands
Important Linux CommandsImportant Linux Commands
Important Linux Commands
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformatics
 
Unix slideshare
Unix slideshareUnix slideshare
Unix slideshare
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Basic Linux commands
Basic Linux commandsBasic Linux commands
Basic Linux commands
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
 
BASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUXBASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUX
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux commd
Linux commdLinux commd
Linux commd
 
Linux commd
Linux commdLinux commd
Linux commd
 
Linux cheat-sheet
Linux cheat-sheetLinux cheat-sheet
Linux cheat-sheet
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Linux commands part -2
Linux commands part -2Linux commands part -2
Linux commands part -2
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
 
One Page Linux Manual
One Page Linux ManualOne Page Linux Manual
One Page Linux Manual
 
Basics of unix
Basics of unixBasics of unix
Basics of unix
 
Top 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsTop 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu Commands
 
Linux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for BeginnersLinux Bash Shell Cheat Sheet for Beginners
Linux Bash Shell Cheat Sheet for Beginners
 

Viewers also liked

25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examplesTeja Bheemanapally
 
Ripple lab wcg项目教程最终
Ripple lab  wcg项目教程最终Ripple lab  wcg项目教程最终
Ripple lab wcg项目教程最终Liu Kan
 

Viewers also liked (10)

50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
In a monolithic kerne1
In a monolithic kerne1In a monolithic kerne1
In a monolithic kerne1
 
25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Shell intro
Shell introShell intro
Shell intro
 
Virtualization
VirtualizationVirtualization
Virtualization
 
Intro on computers
Intro on computersIntro on computers
Intro on computers
 
Ripple lab wcg项目教程最终
Ripple lab  wcg项目教程最终Ripple lab  wcg项目教程最终
Ripple lab wcg项目教程最终
 
In a monolithic kerne1
In a monolithic kerne1In a monolithic kerne1
In a monolithic kerne1
 
Dbms record
Dbms recordDbms record
Dbms record
 

Similar to 40 basic linux command

Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
PrashantTechment
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
Sreenatha Reddy K R
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
LuigysToro
 
Group13
Group13Group13
BASICS OF LINUX OPERATING SYSTEM.pptx
BASICS OF LINUX OPERATING SYSTEM.pptxBASICS OF LINUX OPERATING SYSTEM.pptx
BASICS OF LINUX OPERATING SYSTEM.pptx
AlkaYadav79
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Linux presentation
Linux presentationLinux presentation
Linux presentationNikhil Jain
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
Shakeel Shafiq
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
vamsikrishna204239
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
vamsikrishna204239
 
Programming Embedded linux
Programming Embedded linuxProgramming Embedded linux
Programming Embedded linux
Liran Ben Haim
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
Kedar Bhandari
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic Commands
Shankar Mahure
 
Linux commands
Linux commandsLinux commands
Linux commands
Meenu Chopra
 
Internal commands of dos
Internal commands of dosInternal commands of dos
Internal commands of dos
Nargiskhan786
 
Assignment OS LAB 2022
Assignment OS LAB 2022Assignment OS LAB 2022
Assignment OS LAB 2022
INFOTAINMENTCHANNEL1
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
iman darabi
 
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCAAARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AaravNayan
 
Directories description
Directories descriptionDirectories description
Directories description
Dr.M.Karthika parthasarathy
 

Similar to 40 basic linux command (20)

Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
Group13
Group13Group13
Group13
 
BASICS OF LINUX OPERATING SYSTEM.pptx
BASICS OF LINUX OPERATING SYSTEM.pptxBASICS OF LINUX OPERATING SYSTEM.pptx
BASICS OF LINUX OPERATING SYSTEM.pptx
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Programming Embedded linux
Programming Embedded linuxProgramming Embedded linux
Programming Embedded linux
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic Commands
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Internal commands of dos
Internal commands of dosInternal commands of dos
Internal commands of dos
 
Assignment OS LAB 2022
Assignment OS LAB 2022Assignment OS LAB 2022
Assignment OS LAB 2022
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
 
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCAAARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
 
Directories description
Directories descriptionDirectories description
Directories description
 

More from Teja Bheemanapally (20)

Teradata
TeradataTeradata
Teradata
 
Teradata
TeradataTeradata
Teradata
 
Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questions
 
Linux notes
Linux notesLinux notes
Linux notes
 
Linux crontab
Linux crontabLinux crontab
Linux crontab
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux01122011
Linux01122011Linux01122011
Linux01122011
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 
Installing red hat enterprise linux1
Installing red hat enterprise linux1Installing red hat enterprise linux1
Installing red hat enterprise linux1
 
Linux basic commands tutorial
Linux basic commands tutorialLinux basic commands tutorial
Linux basic commands tutorial
 
Common linuxcommandspocketguide07
Common linuxcommandspocketguide07Common linuxcommandspocketguide07
Common linuxcommandspocketguide07
 
Basic commands
Basic commandsBasic commands
Basic commands
 
File system hierarchy standard
File system hierarchy standardFile system hierarchy standard
File system hierarchy standard
 
15 practical grep command examples in linux
15 practical grep command examples in linux15 practical grep command examples in linux
15 practical grep command examples in linux
 
25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples25 most frequently used linux ip tables rules examples
25 most frequently used linux ip tables rules examples
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot process
 
Kernel (computing)
Kernel (computing)Kernel (computing)
Kernel (computing)
 
Installing red hat enterprise linux1
Installing red hat enterprise linux1Installing red hat enterprise linux1
Installing red hat enterprise linux1
 
In a monolithic kernel
In a monolithic kernelIn a monolithic kernel
In a monolithic kernel
 
Ftp
FtpFtp
Ftp
 

Recently uploaded

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 

Recently uploaded (20)

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 

40 basic linux command

  • 1. 40 Basic Linux Command-line Tips and Tricks 1. Everything in Linux is a file including the hardware and even the directories. 2. # : Denotes the super(root) user 3. $ : Denotes the normal user 4. /root: Denotes the super user’s directory /home: Denotes the normal user’s directory. 5. Switching between Terminals § Ctrl + Alt + F1-F6: Console login § Ctrl + Alt + F7: GUI login 6. The Magic Tab: Instead of typing the whole filename if the unique pattern for a particular file is given then the remaining characters need not be typed and can be obtained automatically using the Tab button. 7. ~(Tilde): Denotes the current user’s home directory 8. Ctrl + Z: To stop a command that is working interactively without terminating it. 9. Ctrl + C: To stop a command that is not responding. (Cancellation). 10. Ctrl + D: To send the EOF( End of File) signal to a command normally when you see ‘>’. 11. Ctrl + W: To erase the text you have entered a word at a time. 12. Up arrow key: To redisplay the last executed command. The Down arrow key can be used to print the next command used after using the Up arrow key previously. 13. The history command can be cleared using a simple option –c (clear). 14. cd : The cd command can be used trickily in the following ways: cd : To switch to the home user cd * : To change directory to the first file in the directory (only if the first file is a directory) cd .. : To move back a folder cd - : To return to the last directory you were in 15. Files starting with a dot (.) are a hidden file. 16. To view hidden files: ls -a 17. ls: The ls command can be use trickily in the following ways:
  • 2. ls -lR : To view a long list of all the files (which includes directories) and their subdirectories recursively . ls *.* : To view a list of all the files with extensions only. 18. ls -ll: Gives a long list in the following format drwxr-xr-x 2 root root 4096 2010-04-29 05:17 bin where drwxr-xr-x : permission where d stands for directory, rwx stands for owner privilege, r-x stands for the group privilege and r-x stands for others permission respectively. Here r stands for read, w for write and x for executable. 2=> link count root=>owner root=>group 4096=> directory size 2010-04-29=>date of creation 05:17=> time of creation bin=>directory file(in blue) The color code of the files is as follows: Blue: Directory file White: Normal file Green: Executable file Yellow: Device file Magenta: Picture file Cyan: link file Red: Compressed file File Symbol -(Hyphen) : Normal file d=directory l=link file b=Block device file
  • 3. c=character device file 19. Using the rm command: When used without any option the rm command deletes the file or directory ( option -rf) without any warning. A simple mistake like rm / somedir instead of rm /somedir can cause major chaos and delete the entire content of the /(root) directory. Hence it is always advisable to use rm command with the -i(which prompts before removal) option. Also there is no undelete option in Linux. 20. Copying hidden files: cp .* (copies hidden files only to a new destination) 21. dpkg -l : To get a list of all the installed packages. 23. Use of ‘ > ‘ and ‘ >> ‘ : The ‘ > ‘ symbol ( input redirector sign) can be used to add content to a file when used with the cat command. Whereas ‘ >> ‘ can be used to append to a file. If the ‘ >> ‘ symbol is not used and content is added to a file using only the ‘>’ symbol the previous content of the file is deleted and replaced with the new content. e.g: $ touch text (creates an empty file) $ cat >text This is text’s text. ( Save the changes to the file using Ctrl +D) $cat >> text This is a new text. (Ctrl + D) Output of the file: This is text’s text. This is a new text. 23. To count the number of users logged in : who |wc –l 24. cat: The cat command can be used to trickly in the following way: - To count no. of lines from a file : cat <filename> |wc -l - To count no. of words from a file : cat <filename> |wc -w - To count no. of characters from a file : cat <filename> |wc –c 25. To search a term that returns a pattern: cat <filename> |grep [pattern] 26. The ‘tr’ command: Used to translate the characters of a file. tr ‘a-z’ ‘A-Z’ <text >text1 : The command for example is used to translate all the characters from lower case to upper case of the ‘text’ file and save the changes to a new file ‘text1′.
  • 4. 27. File permission using chmod: ‘chmod’ can be used directly to change the file permission of files in a simple way by giving the permission for root, user and others in a numeric form where the numeric value are as follows: r(read-only)=>4 w(write)=>2 x(executable)=>1 e.g. chmod 754 text will change the ownership of owner to read, write and executable, that of group to read and executable and that of others to read only of the text file. 28. more: It is a filter for paging through text one screenful at a time. Use it with any of the commands after the pipe symbol to increase readability. e.g. ls -ll |more 29. cron : Daemon to execute scheduled commands. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. 1 * * * * echo “hi” >/dev/tty1 displays the text “hi” after every 1 minute in tty1 .—————- minute (0 – 59) | .————- hour (0 – 23) | | .———- day of month (1 – 31) | | | .——- month (1 – 12) OR jan,feb,mar,apr … | | | | .—– day of week (0 – 7) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat * * * * * command to be executed Source of example: Wikipedia 30. fsck: Used for file system checking. On a non-journaling file system the fsck command can take a very long time to complete. Using it with the option -c displays a progress bar which doesn’t increase the speed but lets you know how long you still have to wait for the process to complete. e.g. fsck -C 31. To find the path of the command: which command e.g. which clear 32. Setting up alias: Enables a replacement of a word with another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command
  • 5. e.g. alias cls=’clear’ => For buffer alias of clear 33. The du (disk usage) command can be used with the option -h to print the space occupied in human readable form. More specifically it can be used with the summation option (-s). e.g. du -sh /home summarizes the total disk usage by the home directory in human readable form. 34. Two or more commands can be combined with the && operator. However the succeeding command is executed if and only if the previous one is true. e.g. ls && date lists the contents of the directory first and then gives the system date. 35. Surfing the net in text only mode from the terminal: elinks [URL] e.g: elinks www.google.com Note that the elinks package has to be installed in the system. 36. The ps command displays a great more deal of information than the kill command does. 37. To extract a no. of lines from a file: e.g head -n 4 abc.c is used to extract the first 4 lines of the file abc.c e.g tail -n 4 abc.c is used to extract the last 4 lines of the file abc.c 38. Any changes to a file might cause loss of important data unknowingly. Hence Linux creates a file with the same name followed by ~ (Tilde) sign without the recent changes. This comes in really handy when playing with the configuration files as some sort of a backup is created. 39. A variable can be defined with an ‘=’ operator. Now a long block of text can be assigned to the variable and brought into use repeatedly by just typing the variable name preceded by a $ sign instead of writing the whole chunk of text again and again. e.g ldir=/home/my/Desktop/abc cp abcd $ldir copies the file abcd to /home/my/Desktop/abc. 40. To find all the files in your home directory modified or created today: e.g. find ~ -type f -mtime 0 http://www.yolinux.com/TUTORIALS/LinuxTutorialSysAdmin.html