Linux Commands Flashcards

1
Q

what is cmd to clear the screen in terminal?

A

clear (short cut: Ctrl + L)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the cmd to show the current working directory?

A

pwd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the cmd to list the folders of the current directory?

A

ls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the cmd to list all the processes currently running?

A

ps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the cmd to get the operation system which is currently running?

A

uname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the cmd to end the terminal / shell?

A

exit (shortcut : Ctrl + d)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what does command “ls- a” do?

A

Will list all hidden files which start with a “.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what does command “ls- l” do?

A

List the list of visible files in a long format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what command is used to access the help manuals built in?

A

man <option> <command></command></option>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the File System Hierarchy Standard which is currently used?

A

FHS 3.0 released on June 03, 2015

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the file system structure

A

Level 0 - root (/)
Level 1 - sbin , media, bin, etc(apt),home(lenin,Desktop, Documnents, Downloads, Pictures, MyCode), tmp, user(bin, sbin,share),lib, var,mnt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

File System: traversing the tree

A

/ is the root of the file system
/ is also the delimiter for sub-directories
. is current directory
.. is parent directory
path for traversal can be absolute or relative

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the components of typical output of ls -l ?

A

drwxr -xr -x 5 gphani gphani 12288 Nov 25 10:00 Documents

here “d” denotes file type , here it is directory

rwx (owner permissions)
r-x (Group permissions, - denotes no permission)
r -x (Others permissions)
5 - Number of hard links
gphani - owner
gphani - group (by default there is a group in every user name)
12288 - size
Nov 25 10:00 - Last modified timestamp
Documents - filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

in ls -l format , what does the file descriptor say?

A

L stands for link to a different directory( like a shortcut)
D stands for directory
- symbolizes regular file
d symbolizes Directory
l symbolizes symbolic link
c symbolizes character file
b symbolizes block file
s symbolizes socket file
p symbolizes Named pipe

C stands for character file which could be read
B stands for Block devices like HDD where data will be read/written in blocks. Typical linux block size is 1Kb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an inode?

A

ls -i <name>
An entry in the filesystem table about the location in storage media
Each unique file will have a unique inode.
If there are multiple entries for the same inode then they are called hard links</name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a hard link?

A
17
Q

how to go back to our user root directory

A

by typing command cd without any arguments.

18
Q

What does the file system directories contain?

A

/bin - Essential cmd binaries (could be a link to /usr/bin)
/boot - static files of the boot loader
/dev - device files (Every device in linux is a file)
/etc - host specific system configuration
/lib - essential shared libraries and kernel modules
/media - mount points for removable devices
/mnt -mount points
/opt - Add on application software packages
/run - Data relevant to running processes
/sbin - Essential system binaries
/srv - Data for services (eg. FTP, HTTP services)
/tmp - Temperory files
/usr - secondary hierarchy (shareable user directory)
/var - variable data (log files)

19
Q

What are the various directories in /usr hierarchy?

A

/usr/bin - User Commands (all available commands for user)
/usr/lib - Libraries (user specific libraries, may not be available for other users)
/usr/local - Local hierarchy
/usr/sbin - Non-vital system binaries
/usr/share - Architecture dependent data
/usr/include - Header files included by C programs
/usr/src - Source code of various installed applications

20
Q

What are the various directories in /var hierarchy?

A

/var/cache - Application cache data
/var/lib - variable state information
/var/local - variable data for /usr/local
/var/lock - lock files
/var/log - log files and directories
/var/run - data relevant to running processes
/var/tmp - temperory files preserved between reboots

21
Q

What is the difference between a sharable folder vs an unshareable folder?

A

sharable - a file system that could be shared with many computers to converse storage and uniform file system.
Vs Unshareable.

static shareable - /usr, /opt
static unshareable - /etc, /boot
variable sharable - /var/mail
variable unshareable -/var/run, /var/lock

22
Q

what does the date command do?

A

displays current date and time (as set in local computer)

date -R (email format, 24 hr format with GMT)

23
Q

How to display the dates a file was edited?

A

date –f <file></file>

24
Q

What does the command cal do?

A

displays the calender

cmd “ncal” displays calender in different orientation than that of the command “cal”.. ie., transposes the output of the command “cal”

25
Q

What does the command “free” do?

A

displays memory statistics

free -h (displays in human readable format)clerar

26
Q

What does the command “groups” do?

A

displays groups to which user belongs

27
Q

what does the command “file” do?

A

displays the type of file

28
Q

How to display all the file types in a particular directory?

A

file *

29
Q

what does command “cd -“ do?

A

Takes us to the previous directory we were in

30
Q

what does command “cd ~” do?

A

Take us to home directory .. just like command “cd”

. is shortcut for current directory
.. is shortcut for parent directory
- is shortcut for previous directory
~ is shortcut for home directory

31
Q

how to create multiple directories at the same time?

A

mkdir dir1 dir2

32
Q

how to delete a directory?

A

rmdir dir1

The rmdir or rm -d command is for removing empty directories, while the rm -r command deletes non-empty directories.

33
Q

Which command will give information on open network ports on the machine?

A

netstat

34
Q

what does command wget do?

A

Wget is a command-line tool that makes it possible to download files from the internet directly to your active directory. It operates in the background, allowing tasks to continue even if you’re offline. The name is a combination of World Wide Web and the word get. It supports downloads via FTP, SFTP, HTTP, and HTTPS