Advertisement

Linux Advance Interview Question And Answer ( Linux Advance Command) Linux Series- 2

Linux Advance Interview Question And Answer ( Linux Advance Command) Linux Series- 1

1) Which command in Linux is used to print information about the system and its

environment?

->$ uname

2)Which command in Linux is used to get more info about the system?

->$ uname -a

3)Which command is used to print the ip address?

->$ ifconfig

4)If ifconfig is not getting recognized by the system then which package we have

to install,again what will be the command?

->$ sudo yum install net-tools

5)How to check the user-name in linux?

->$ whoami

6)How to check the machine os,which command is used?

->$ cat /etc/os-release

7)How to print the shell name?

->$ echo $SHELL or $echo $0

8)Which command in Linux is used to determine the execution time of a given

command or process? Also give one example.

->$ time command_name

Example:-time ls

9)Which command is used to list down all the available shells ?

->$ cat /etc/shells

10)Give names of any two shells?

->

/bin/sh

/bin/bash

/bin/ksh

11)If we want to shift to sh shell,which command we have to use?

->$ sh

12)Which command is used to check the current shell ?

->echo $0

13)How to check the host name?

->$ hostname OR uname

14)Which command is used to check user and userinfo?

->$ cat /etc/passwd (uid , gid ,etc)

15)What is the id of the root user?

-> 0

16)In which range system users have their id?

-> 1-999

17)What is the id of ec2-user?

-> 1000

18)In which range normal users have their id?

-> Above 1000 (1001-1999)

The range in which group id exist?

Above 2000

19)Which command is used to print the present working directory?

->$ pwd

20)Which command is used to print the string?

->$ echo “string_name”

21)How to check the reboot time of the system?

->

$who -b ( shows reboot time)

$uptime -s ( show reboot time and date)

$last reboot ( show the history of the reboot)

22)How to change the date and time?

->$ sudo date -s 'Fri Apr 14 09:30:00 AM UTC 2002'

19)Which command is used to display the manual page of a command?

->$ man command_name

Example: $ man ls

20)Use of mandb

-> It is used to create or update the manual page database on the system.

21)The command in Linux is used to locate the executable file that will be

executed when a given command is run in the shell.

Shows the full path of the command.

->$which ls

22)The command that shows the directories that your shell will search through

when you entered a command

-> echo $PATH

***This two commands are same : echo $USER or whoami***

23)How to change the name, primary prompt, secondary prompt?

->

$PS1='Adhiraj'

$PS2='Sakshi @'

ec2-user@172.3.3.3 $

Adhiraj $ echo ‘ Hi ← PS1 (Adhiraj)

Sakshi @ hello ← PS2 (Sakshi @)

Sakshi @ hi’

24)How to create a user?Create one user

->

$sudo useradd username

Example: sudo useradd adhiraj

25)How to change the password of newly created user?Change the password of

adhiraj user

->

$sudo passwd username

Example: sudo passwd adhiraj

26)How to delete the user?

->$ sudo userdel username

Example: sudo userdel adhiraj

27)How to cleanly delete a user?

->$sudo userdel -r username

Example: sudo userdel -r adhiraj

28)How to create a hidden file?

->touch .file_name

29)In Linux, which file is the encrypted password file?

->sudo cat /etc/shadow

30)How to add a group?

->$sudo groupadd demo

31)If you want to create a group with a specific group ID then which command

have to be used?Also give example

->

$sudo groupadd -g group_id group_name

$sudo groupadd -g 1009 demo

32)How to change the group ID of existing group?Change the ID of demo group

which you have created earlier

->

$sudo groupmod -g new_ID groupname

$sudo groupmod -g 1111 demo

33)If we want to rename the group name,then how to do it?Change the name of

demo group which you have created earlier and rename it to test

->

$sudo groupmod -n new_name oldername

$sudo groupmod -n test demo

34)How to add a user in a group?Add a user name adhiraj to your test group

->

$sudo usermod - aG groupname username

$sudo usermod -aG test adhiraj

35)How to remove a user from group?Remove user adhiraj from test group

->$sudo gpasswd --delete username groupname

$sudo gpasswd --delete adhiraj test

36)How to delete a group?Delete group test

->$sudo groupdel test

37)Which command is used to list the contents in the current working directory?

->$ls

38)Which command is used to list the data according to time?

->$ls -lt

39)Which command is used to list the data according to time but in reverse order?

->$ls -ltr

40)How can we see the hidden files present in the directory?

Create a hidden file first and then display it

->

Create hidden file

$touch .hidden.txt

Display hidden file

$ls -a

41)How to list down the files created by a specific author?

->$ls --author

42)How to sort as well as list down all the contents in the current working

directory?

->$ls -s

43)How to list down the files of particular extension?List down all the files of txt

format

->$ls *.txt

44)How to change the directory?Suppose you have to change it to folder1

->$cd folder1

45)How to move to the home directory?

->$cd ~

46)How to change the current working directory to the root directory?

->$cd /

47)How to move to the previously used directory?

->$cd ..

48)How to open a file?

->$cat filename

49)Create a new file name new.txt using cat command and insert a data into it

->$cat > new.txt

An apple a day keeps the doctor away.

50)Now append data in new.txt file using cat command.

->$cat>>new.txt

I love apples.

Post a Comment

0 Comments