151)Which command in Linux is a real-time process monitoring tool that
provides a dynamic overview of the system's current resource usage, including
CPU, memory, and other system statistics.
->$top
152)What is the use of -e? Also give one example.
->If we want to print a word or line in new line than we can use -e
Example:- $echo -e "Hello\nWorld"
153)Write a program which will create a beep sound.
->$echo -e "Hello\a\a\a\aworld"
154)Write a command to change the colour(Make it Red) of word sakshi
->echo -e "\e[1;31m sakshi\e[0m "
155)Write a process to create and execute a script .
->Step1:=$vi sleep.sh
Step2:= Press i
Step3:=Write a code
#!/bin/bash
echo "a"
sleep 1
echo "b"
sleep 1
echo "c"
sleep 1
echo "d"
sleep 1
echo "e"
sleep 1
echo "d"
sleep 1
echo "e"
sleep 1
echo "f"
sleep 1
echo "g"
sleep 1
echo "h"
sleep 1
echo "i"
sleep 1
echo "j"
Step4:=Press :wq
Then hit enter
Step5:=./sleep.sh
156)How to terminate the currently executing process.
->$ctrl+c
157)How to pause the currently executing process.
->$ctrl+z
158)How to start the paused process again.
->$fg
159)How to start the paused process again but in the background.
->$bg
160)Which command is used to monitor the contents of a file in real-time,
particularly log files, by displaying the last few lines of the file and
continuously updating the display as new lines are added to the file.
->$tail -f filename
161)Which command is used to list the available signal names or numbers on a
Unix-like system.
->$kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
162)Which command is used to display detailed information about processes
running on a Unix-like system. It provides a full listing of processes in
a "long" format, showing information such as the process ID (PID), parent proce
(PPID), CPU and memory usage, start time, and command
associated with each process.
->ps -f
163)Alternate to(ctrl+z) stop the currently executing process.
->$kill -19 PID_NUMBER
164)Alternate to(fg and bg) to resume the currently executing process.
->$kill -18 PID_NUMBER
165)Alternate to(ctrl+c) terminate the currently executing process.
->$kill -9 PID_NUMBER
166)Which command used in Unix-like operating systems to run a command or
script that will continue running even after the user logs out or
terminates the session. It stands for "no hangup."Give one example
->Step 1:- vi sleep2.sh
Step2:-#!/bin/bash
>number.txt
for N in {1..1000}
do
echo ${N}>>numbers.txt
echo Hello$N
sleep 1
done
Step3:-chmod u+x sleep2.sh
Step4:-nohup ./sleep2.sh &
167)How to kill the process?Kill sleep2.sh
->pkill -f sleep2.sh
168)Which command is used to display RAM status.
->$free
169)Which command is used to display disk space usage (disk free)
->$df or $df -h
170)Which command is used in Unix-like operating systems to estimate file and
directory disk usage. Which provides information about the space
occupied by files and directories, helping you analyse disk usage on your system.
->$du -h (disk usage)
171)Declare a variable BASIC,DA,TA,HRA,GROSS assign BASIC as 7000 and find
the GROSS salary also display it on terminal.
->#!/bin/bash
BASIC=70000
DA=`echo ${BASIC} \*.1 | bc`
TA=`echo ${BASIC} \*.1 | bc`
HRA=`echo ${BASIC} \*.1 | bc`
GROSS=`echo ${BASIC} + ${DA} + ${TA} + ${HRA} | bc
echo The Gross Salary is ${GROSS}
172)Write a script using the read command.
->#!/bin/bash
read -p "Enter you salary" SAL
echo "Your salary is:"${SAL}
173)Which command is used to start debugging mode.
->$set -x
174)Which command is used in debugging mode.
->$set +x
175)Which command is used to list the cron jobs for the current user,which is a
time-based job scheduler in Unix-like operating systems, and each
user can have their own set of scheduled tasks or jobs.
->$crontab -l
176)Which command is used to edit the crontab command
->$crontab -e
177)Write an example of how to use the crontab command to create and edit cron
jobs.
->Step1:-To edit the cron jobs for the current user, use the following command:
$crontab -e
Step2:-The general format of a cron job line is as follows:
$* * * * * command or $* * * * */path/to/command
For example, to schedule a command to run every day at 9:30 AM, you can add the
following line:
$30 9 * * * /home/ec2-userW/to/command
Step3:-To view the updated list of cron jobs, you can use the crontab -l command:
$crontab -l
178)Write a script to hide password while writing
->#!/bin/bash
read -p "Enter name:" UNAME
read -sp "Enter password:" PASSWARD
179)Example of command line argument
->Step1:- vi ex2.sh
Step2:-#!/bin/bash
# Access the first command-line argument
name=$1
# Display a greeting message
echo "Hello, $name! Welcome to Linux."
Step3:-./ex2.sh sakshi
180)Write a program to concatenate two strings.
->Step1:-vi ex3.sh
Step2:-#!/bin/bash
# Access the first command-line argument
name=$1
surname=$2
# Display a greeting message
echo "Hello," $name $surname" ! Welcome to Linux."
Step3:-./vi ex3.sh sakshi sawalikar..
181)Use expr to add two whole numbers.
->$expr 20+30 | bc
182)Use expr to add two decimal numbers
->expr 20.5+20.5 | bc
183)Use bc two add two whole numbers
->echo 20+24 | bc
184)Use bc two add 20.5 and 74
->echo 20.5+74 | bc
185)Write a command to convert decimal to binary.
->echo "ibase=10;obase=2;47" | bc
186)Write a command to convert decimal to octal.
->echo "ibase=10;obase=8;47" |bc
187)Write a command to convert decimal to hexadecimal.
->echo "ibase=10;obase=16;47" | bc
188)Write a command to compress a file.
->$gzip filename
189)Write a command to decompress a file
->$gzip -d filename.gz
190)How to tar and untar a file.
-> tar a file: $ tar -cvf archive.tar /path/to/your/file
untar a file: $ tar -xvf archive.tar
0 Comments