[go: up one dir, main page]

0% found this document useful (0 votes)
602 views6 pages

Session-1: 50 Most Useful Linux Commands: Category-1: File System Management

The document summarizes useful Linux commands organized into categories of file system management, text processing, and process management. Some key commands covered include ls to list files, mkdir to create directories, cp to copy files, grep to search text, top or htop to view system processes and resources, and kill to terminate processes. The document provides examples of using each command and brief explanations of their functions.
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)
602 views6 pages

Session-1: 50 Most Useful Linux Commands: Category-1: File System Management

The document summarizes useful Linux commands organized into categories of file system management, text processing, and process management. Some key commands covered include ls to list files, mkdir to create directories, cp to copy files, grep to search text, top or htop to view system processes and resources, and kill to terminate processes. The document provides examples of using each command and brief explanations of their functions.
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/ 6

Team VLSI Linux Session

Session-1: 50 Most useful Linux commands


Category-1: File System Management

1. ls : list files and directories


ls -l ; indicates file/directory type, permissions, owner, size, last modified
- normal, d- directory, s-socket file, l-link file
ls -a ; shows hidden files/directories
ls -t ; lists the files/directory on basis of modification time
2. clear : clear the terminal

3. man / --help : manual of command and switches

4. pwd : Print Working Directory

5. cd : Change Directory
cd .. ; back to parent directory
cd - ; back to previous directory
cd ~ ; go to home directory
cd ../ ../ ../ ; back to n steps
cd ‘abc xyz’ ; go to a directory whose name contain white space

6. mkdir : create a directory


mkdir directory_name ; make directory for creating a new directory

7. touch : create a file


touch file_name ; create a new file
touch file1 file2 file3 ; To create multiple files
touch –a file_name ; to change file access time
touch –m file_name ; to change file modification time

8. gedit file_name & : create and edit a file in GUI mode


gedit /path/to/file_name ; create and edit a file in specified location
; word count, line no. , language
9. vi file_neme : create and edit a file using command line interface
i ; insert the text
/string ; find the string
Esc + :q ;exit without saving
Esc + :s ; Save only not exit
Esc + :wq ; save and exit

10. cp source destination : copy command


cp -f ; force , not a regular file
cp -R ; recursive coping of a directory
11. mv source destination : move command, like cut+paste
mv f1 f2 ; rename f1 by f2
mv -rf ; recursive and force moving of a directory
Team VLSI Linux Session
Session-1: 50 Most useful Linux commands
Category-1: File System Management

12. rm : remove file/directory , like delete

rm -rf ; remove recursive and force


rm *.txt ; remove all the file having extension .txt in PWD
rm -rf ; one of dangerous command as root
13. cat : stands for concatenate
cat file_name ; Display a contain of file
cat –n file_name ; display file with line number
cat text1 > text2 ; redirection of text , overwrite
cat text1 >> text2 ; appending the text
14. which :Path of the command

15. locate :searching a file/directory


locate -S ; review your database
locate file_name ; get the path of file
locate -i file_name ; search by ignoring case sensitivity

16. history : Get the list of executed commands


history ; history of all command
history n ;list of last n command executed
!n ; repeat any command in the history list
export HISTTIMEFORMAT=‘%F %T ’ ; seting history commnd
with time stamp format
unset export HISTTIMEFORMAT ; unsetting the time format
history -c ; clear all the history
~/.bash_history ; location of stored command history

17. chmod : Change mode, change the permission of file/directory


ls -l file_name ; See the current permissions of the file/dir

2 1: file or directory (- or d ) - : file


1 3 4 5
6 2. Permission for owner d : directory
3. Permissin for Group
4. Permissions for Others r : read
5. Ower w : write
6. Group x : execute/search
r w x
4 2 1
Numeric and Symbolic permissions
7 7 7
rwx rwx rwx
chmod 777 file_name ; set all the permission for all users
7 5 4 chmod 754 file_name ; set rwx for owner, r-x for group and and r–
rwx r-x r- - for others
chmod –R 777 dir_name ; Set all permission recursively inside the dir
Team VLSI Linux Session
Session-1: 50 Most useful Linux commands
Category-2: Text processing commands

18. touch : create a new file

touch file1 ; create an empty file


touch file1 file2 file3 ; create multiple files in one command
touch –am file2 ; change access and modification time

19. gedit : A GUI based linux text editor

gedit & ; open gedit text editor


gedit file1 ; create/open a file in geditor

20. head : To read first 10 line in command line

head file_name ; To read first 10 lines of a file


head –n 8 file_name ; To read first 8 lines of a file OR head -8 file
head -4 *.log ; Read first 4 lines of all log files in PWD

21. tail : To read last 10 line in command line

tail file_name ; To read last 10 lines of a file


tail –n 12 file_name ; To read last 12 lines of a file OR tail -2 file

22. sort : To sort the list


sort file_name ; sort the content of file
sort –n file_name ; sorting a file which has numbers
sort –r file_name ; sorting the file in reverse order
sort –o outputfile inputfile ; redirection of sorted output
sort –n -k2 file_name ; sorting the file on basis of nth coloumn

23. unique : An utility for filtering the repeated lines in a file


unique file_name ; will display only unique lines
unique –c file_name ; will tell no. of times a lines has repeated

24. more : Display text one screen at a time


more file_name ; display the text in command line
<space> next screen, <b> back to previous
screen, <enter> next line
More -10 file_name ; will display 10 lines at a time
dmesg | more ; will tell no. of times a lines has repeated

25. less : to read the text file in command line


less file_name ; similar to more command with some advance features

26. grep : global regular expression print


grep –i words file_name ; display the line contains searched word
dmesg | grep sda ; filtered the output and show only line having sda
dmesg | grep sda –A 5 ; Display 5 lines after the matching word sda
Team VLSI Linux Session
Session-1: 50 Most useful Linux commands
Category-2: Text processing commands

27. diff : find difference between two files/dir

diff file1 file2 ; To check the difference between two files


diff dir1 dir2 ; To check the difference between contain of two dir
A similar GUI tool is “meld”
vimdiff f1 f2 , gvimdiff f1 f2
28. wc : word count of a file

wc file_name ; New line, word and byte count in the file


wc –l file_name ; To count total new lines in the file
wc –w file_name ; T count total words only
wc –c file_name ; T count total characters only

Category-3: Process management commands

29. top or htop : It will show status of various resources and tasks
top ; you can see the utilization statics for resources and get PID
of all running process
htop ; Simillar to top but improved version.

30. ps : Known as Process Status


ps ; process for current shell
ps -e ; Display all active process
ps -ef ; Display all active process in full format
ps –ef | grep virtuoso ; If the list is too big we can grep it to
specific command

31. kill : To terminate a process


kill PID ; Killing a process by PID, PID is a numeric value.
kill PID1 PID2 PID3 ; Kill multiple process together. You can specify
the signal name in between Kill and PID. If no signal has been
specified, by default TERM signal will be sent.

32. who : Display the users who are currently logged in your Linux machine
who ; Without any argument who command will display user’s
login name, terminal, login time and host
who –q ;Display the name of all users and total no. of users logged in

33. w : information about current logged user and what they are doing

34. users : Display the all current users name in a single line

35. last : it display the list of user who logged the system
last ; If no options provided last command displays a list of all users
logged in (and out) since /var/log/wtmp file was created
last user_name ;Will display the activities of a particular user only
Team VLSI Linux Session
Session-1: 50 Most useful Linux commands
Category-3: Process management commands
36. free : Used to check available physical memory and swap memory
free ; Command used to checked used and free memory space in KB
free –m/g ;Space will be shown in MB or GB
free -s 5 ; Will update the status in every 5 seconds.

37. lshw : Used to check hardware information


lshw ; Generates detail reports about various hardware of system
lshw –class memory ;Details memory in the system
lshw –class processor ; Details of processor in the system
lshw –short –class disk ; Details about the hard drives (network)

38. lscpu : Display information about CPU architecture


lscpu ; Give the detailed information about the CPU

39. cat /proc/cpuinfo : Similar information like lscpu


40. dmidecode : Is a tool for dumping System Management BIOS (SMBIOS)
table content in human readable format
dmidecode ; Gives all the hardware details
dmidecode –t system ; Gives the manufacturer, model no. etc details
dmidecode –t bios ; Gives the bios information of system (/memory)
41. uptime : Gives the time how long system is running
uptime -p ; Gives the duration of system running
42. reboot : Will shutdown and restart the machine instantly

43. shutdown : Can be used to shutdown or restart the machine


shutdown –h now ; System will be shutdown instantly
shutdown –h +5 “message” ; System will be shutdown after 5 minute
shutdown –r +5 ; System will be restart after 5 minutes

Category-4: Bash Environment related commands


44. date : Will show the current date, time and of time zone
date ; Will show day, date, current time and timezone
date –d “1990-12-31” ; Details of any specific date
timedatectl ; Will show details of local and universal time and timezone
timedatectl set-time ‘2018-12-27 07:30:10’ ; to set specific date and time
timedatectl set-time ‘Asia/Kolkata’ ; Setting time by time zone

45. cal : Will display the calendar of current month in terminal

cal ; Will show calendar of current month in terminal


cal 08 1947 ; To display a calendar of particular month and year
cal –y 2019 ; Will show calendar of all month of a particular year
46. env : Used to print all the current environment variables and it’s
value
Team VLSI Linux System Administration

Category-4: Bash Environment related commands

47. whoami : prints the username of current user

48. uname : It provides kernel versions and other details


uname ; Without any option, will print kernel name only
uname -a ; Get all the information like, kernel name, version,
architecture, host name, current date and time.
49. hostname : To know the hostname
hostname ;It will display the hostname
cat /etc/hostname ;Inside the hostname file hostname is stored and
we can read and edit.
vi /etc/hostname ;to change a new hostname edit the name here
and reboot the machine

50. echo $BASH_VERSION : To know the BASH version. For more


variables value run env command

You might also like