Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views5 pages

Other Commands

The document provides an overview of various Linux commands including 'man' for viewing manual pages, 'grep' for searching text patterns, 'more' for paging through files, 'sort' for ordering text, 'wc' for counting lines and words, 'du' for disk usage, 'df' for available disk space, 'cal' for displaying calendars, 'date' for showing system date and time, and 'bc' as a command-line calculator. Each command includes its syntax, common options, and examples of usage. This serves as a quick reference guide for essential Linux commands.

Uploaded by

adhibrazil174
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

Other Commands

The document provides an overview of various Linux commands including 'man' for viewing manual pages, 'grep' for searching text patterns, 'more' for paging through files, 'sort' for ordering text, 'wc' for counting lines and words, 'du' for disk usage, 'df' for available disk space, 'cal' for displaying calendars, 'date' for showing system date and time, and 'bc' as a command-line calculator. Each command includes its syntax, common options, and examples of usage. This serves as a quick reference guide for essential Linux commands.

Uploaded by

adhibrazil174
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Other Commands

man Command
The man command is used to view the manual pages of other commands in Linux. It
provides detailed documentation about commands, their options, usage, and examples.
Syntax:
man [command_name]
Example:
man ls
This shows the manual page for the ls command.

grep Command
The grep command is used in Linux to search for text patterns within files.
Syntax:
grep [options] pattern [file...]
Common Examples:
Command Description
grep "text" file.txt Search for "text" in file.txt
grep -i "text" file.txt Case-insensitive search for "text"
grep -r "text" /path Recursively search in all files
grep -n "text" file.txt Show line numbers of matches
grep -v "text" file.txt Show lines that do not contain "text"
grep -c "text" file.txt Count the number of matching lines

more Command
The more command in Linux is used to view the contents of a file one screen at a time,
especially when the file is too long to fit on a single screen. It's a simple pager command.
Syntax
more [options] filename
Example
more myfile.txt
This displays the contents of myfile.txt one screenful at a time.
Navigation in more
Enter → Move one line forward
Space → Move one screen forward
b → Move one screen backward (if supported)
q → Quit viewing
Options
Option Description
+n Start displaying at line n
-d Show help message (like "Press space to continue")
-c Clear the screen before displaying
-s Squeeze multiple blank lines into one
Example:
more +10 myfile.txt
Starts showing from line 10 of myfile.txt.
sort Command
The sort command in Linux is used to sort lines of text files in a particular order
(alphabetical, numerical, reverse, etc.).
Basic Syntax:
sort [options] filename
Examples:
1. Sort a file alphabetically:
sort names.txt
2. Sort in reverse order:
sort -r names.txt
3. Sort a file numerically:
sort -n numbers.txt
4. Remove duplicate lines while sorting:
sort -u names.txt
5. Sort based on a specific column (field):
sort -k 2 file.txt
6. Sort ignoring case (A = a):
sort -f names.txt
7. Save the sorted output to another file:
sort names.txt > sorted_names.txt

wc Command
The wc (word count) command is used to count lines, words, characters, and bytes in a file.
Syntax:
wc [options] filename
Common Options:
Option Description
-l Count number of lines
-w Count number of words
-c Count number of bytes
-m Count number of characters
-L Length of the longest line
Examples:
1. Count lines, words, and bytes in a file:
wc sample.txt
Output:
10 50 300 sample.txt
Means: 10 lines, 50 words, 300 bytes
2. Count only lines:
wc -l sample.txt
3. Count only words:
wc -w sample.txt
4. Count only characters:
wc -m sample.txt
Starts showing from line 10 of myfile.txt.
du Command
The du (disk usage) command in Linux is used to estimate and display the amount of disk
space used by files and directories.
Syntax:
du [options] [file/directory name]
Common Examples:
1. Show disk usage of current directory:
du
2. Show disk usage in human-readable format (KB, MB, GB):
du -h
3. Show total disk usage of a directory:
du -sh /path/to/directory
-s = summary (don't list each subfolder)
-h = human-readable

df Command
The df (disk free) command in Linux is used to display the amount of disk space available on
the file system.
Syntax:
df [options]
Examples:
1. Show disk space usage for all mounted file systems:
df
2. Show in human-readable format (KB, MB, GB):
df -h

cal Command
The cal command in Linux is used to display a calendar in the terminal.
Syntax
cal [options] [[month] year]
Common Examples
1. Show current month calendar
cal
2. Show a specific year
cal 2025
3. Show a specific month and year
cal 7 2025
Displays July 2025
4. Show calendar with Monday as the first day of the week
cal -m
5. Highlight today's date
cal -h
Useful Options
Option Description
-y Show the calendar for the current year
-m Use Monday as the first day of the week
-3 Show previous, current, and next month
-h Highlight today
--help Display help message

date command
The date command is used to display or set the system date and time.
Example
date
Displays the current date and time.
output:
Tue Jul 9 10:45:01 IST 2025

bc command
The bc (Basic Calculator) command is used in Linux as a command-line calculator. It supports
arithmetic, floating-point calculations, and math functions.
🔹 Opens an interactive calculator.
🔹 Type expressions and press Enter to evaluate.
Example:
$ bc
5+3
8
10 / 4
2 ← (default: integer division)

You might also like