Hehe Compressed
Hehe Compressed
Index
9. To Stream output format; files are listed across the page, separated by commas(ls -m):
6) Check Version
7) Get help
3) Execute rmdir command with all options
1) Removes the directory mydir.
6) Removes directory
9) Version
5) Execute mv command with all options
1) Rename a File
3) Move a Directory
6) To get help
7) To get version
6) Execute cat command with all options
2) A directory (and all its content) can be copied from source to destination with
the recursive option -r(cp -r source destination)
2. Editing:
• x: Delete the character under the cursor.
• :s/old/new/g: Replace all occurrences of 'old' with 'new' in the current line.
• :%s/old/new/g: Replace all occurrences of 'old' with 'new' in the entire file.
9. Execute uname command with all options
uname –a: all the information can be printed At once by running uname –a
1. gzip command
2. gunzip command
3. tar command
11) Execute ps command with all options.
1: List processes in the current shell (ps)
2: List every process running currently on the system (ps -ef OR ps -aux)
3: List every process on the system using BSD syntax (ps aux)
2. When the free command is used alone, as was demonstrated earlier, without any option, the default
display of the memory is in kilobytes.
3. To view the memory information in megabytes, add the '-m' option to the command
4. To view the memory information in gigabytes, add the '-g' option to the command
5. To view the memory information in human-readable format, add the '-h' option to the command
13) Execute top utility commands with all options.
1.-d, --delay: Specifies the delay between updates in seconds. By default, top updates every 3 seconds.
2. -n, --iterations: Specifies the number of iterations top should run before exiting.
3. -b, --batch: Runs top in batch mode. This is useful for redirecting the output of top to another
program or file.
4. -c, --command: Shows the command line of the processes. This option displays the full command
that launched the process.
5. -i, --ignore-case: Ignores case when searching or sorting.
6. -u, --user: Limits top to display only processes owned by a specific user or users.
7. -p, --pid: Monitors specific process IDs (PIDs). This option allows you to specify one or more PIDs
to monitor.
8. -U, --user=USERNAME: Displays processes owned by a specific user. This is similar to the -u
option, but allows you to specify the username directly.
9. -H, --threads: Enables displaying individual threads for each process. This can provide more
detailed information about thread usage.
14. Execute df commands with all options
1. -a: Shows information about all filesystems, including those with a size of zero blocks.
2. -h: Provides human-readable output, displaying sizes in a more understandable format (e.g., KB,
MB, GB).
4. -t ext4: Limits the output to only show filesystems of type ext4. You can replace ext4 with any
other filesystem type you want to filter.
7. --sync: Forces df to synchronize its output by opening and closing the filesystems being analyzed.
8. -P: Provides POSIX output format, ensuring compatibility with scripts and easier parsing of output.
10. --total: Adds a summary line at the end of the output, showing total usage across all filesystems.
11. --block-size=1G: Sets the block size to 1 gigabyte.
12. --help: Displays a brief help message summarizing the usage of the df command.
15) Execute du command with all options
1. -a: Displays counts for all files, not just directories.
6. /: Specifies the directory to start the disk usage analysis. In this case, it starts from the root
directory.
6. df –b : It will sow the file size in kbs
16) Execute who, who am i, and grep command.
1. Who command: who command is a tool print information about users who are currently logged in.
who command only see a real user who logged in.
2,. Whoami: The 'whoami' command in Linux is a built-in utility that displays the username of the
current user
This command combines the output of "who" with the current username obtained from "whoami"
using a pipe and then filters the output to display only information about the current user.
17. Execute date and time command
1. Displaying the current date and time:
This command will display the current date and time in the format "YYYY-MM-DD HH:MM:SS".
You can customize the format as needed by adjusting the format string within the double quotes.
3. Displaying the date only:
$ date +"%Y-%m-%d"
This command will display only the current date in the format "YYYY-MM-DD".
4. Displaying the time only:
$ date +"%H:%M:%S"
This command will display only the current time in the format "HH:MM:SS".
5. Displaying the day of the week:
$ date +"%A"
This command will display the current day of the week in full format (e.g., "Monday", "Tuesday",
etc.).
18. Write a Shell script to multiplication of two numbers
Program
num1=10
num2=20
ans=$((num1 * num2))
echo $ans
Output
19. Write a Shell script to calculate Division of two numbers
Program
num1=100
num2=20
ans=$((num1 / num2))
echo $ans
Output
20. Write a Shell script to check whether a number is positive or negative
Program
echo "Enter a Number"
read num
if [ $num -lt 0 ]
then
echo "Negative"
elif [ $num -gt 0 ]
then
echo "Positive"
else
echo "Neither Positive Nor Negative"
fi
Output
21. Write a Shell script to find greatest of three numbers
Program
echo "Enter Num1"
read num1
echo "Enter Num2"
read num2
echo "Enter Num3"
read num3
Output
22. Write a Shell script to Print numbers 1 to 100 using while loop
Program
i=1
while [ $i -le 100 ]
do
echo $i i=$
(($i+1))
done
Output
23. Write a Shell script to print sum of all digit
Program
echo "Enter a number"
read num
sum=0
echo $sum
Output
24. Write a Shell script to find largest of n numbers
Program
echo "Enter Size(N)"
read N
i=1
max=0
echo $max
Output
25. Write a Shell script to find average of n numbers
Program
i=1
sum=0
echo $avg
Output
26. Write a Shell script to find factorial of a number
Program
echo "Enter a number"
read num
fact=1
for((i=2;i<=num;i++))
{
fact=$((fact * i))
}
echo $fact
Output