linux Flashcards

1
Q

command to list out all the files or directories available in a directory

A

ls

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

This command lists the account name associated with the current login.

A

whoami

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

Sometime you might be interested to know who is logged in to the computer at the same time.

There are three commands available to get you this information, based on how much you wish to know about the other users:

A

users, who, w

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

command to get a count of the total number of lines, words, and characters contained in a file

A

wc

$ wc filename
2 19 103 filename
$

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

display content of a file and the line numbers

A

cat -n

cat -b (this will not count numbers of empty lines)

$ cat -b filename
1 This is unix file….I created it for the first time…..
2 I’m going to save this content in this file.
$

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

command to make a copy of a file

A

cp

$ cp source_file destination_file

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

command to change the name of a file

A

mv

$ mv old_file new_file

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

command to delete a file

A

rm

$ rm filename

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

formatted directory listing with hidden files

A

ls -al or ls -la

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

change to a directory

A

cd

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

show current directory

A

pwd

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

create a directory

A

mkdir

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

output the contents of a file as it grows

A

tail -f file

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

show kernal config

A

uname -a

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

show this months calendar

A

cal

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

show current date/time

A

date

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

show uptime

A

uptime

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

cpu info

A

cat /proc/cpuinfo

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

memory info

A

cat /proc/meminfo

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

show disk usage

A

df

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

show directory space usage

A

du

and du -sh for human readable version

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

show memory and swap usage

A

free

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

show possible locations of app

A

whereis app

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

search for a pattern in files

A

grep [pattern] files
grep -r pattern dir = search recursively for pattern in dir
command | grep pattern = search for the pattern in the output of the command

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

find all instances of file

A

locate

$locate file

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

halts current command

A

ctrl + c

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

stops current command

A

ctrl + z

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

brings most recent job to foreground

A

fg

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

lists stopped/bacgkround jobs, resume stopped job in the background

A

bg

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

log out of current session

A

ctrl + d

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

erases one word in current line

A

ctrl + w

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

erases whole line

A

ctrl + u

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

reverse lookup of previous commands

A

ctrl + r

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

list of commands used

A

history

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

repeat last command as root

A

!!

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

log out of current session

A

exit

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

brings job n to foreground

A

fg n

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

displays the details of the active user e.g. uid, gid, and groups

A

id

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

shows the last logins in the system

A

last

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

adds the group ‘admin’

A

groupadd “admin”

41
Q

adds the user sam

A

adduser “sam”

42
Q

delets user sam

A

userdel “sam”

43
Q

forcefully removes a file

A

rm -f filename

44
Q

removes a directory recursively

A

rm -r directory_name

45
Q

encripts a file

A

gpg -c file_name

46
Q

decrypts a file

A

gpg file_name.gpg

47
Q

executes commands from standard input

A

xargs

48
Q

lists files that are open by processes

A

lsof

49
Q

find firefox process ID

A

pgrep firefox

50
Q

visualizing processes in tree model

A

pstree

51
Q

kills/terminates all processes named proc

A

killall proc

52
Q

terminates process with a given pid

A

kill pid

53
Q

displays all running processes

A

top

54
Q

displays memory map of processes

A

pmap

55
Q

searches for the id of the process “telnet”

A

ps aux | grep “telnet”

56
Q

sts rwx for owner, rw for group and everyone

A

chmod 766

57
Q

sets rwx to owner and r_x to group and everyone

A

chmod 755

58
Q

sets rwx permissions to owner, group, and everyone (everyone else who has access to the server)

A

chmod 777

59
Q

change owner and group owner of the file

A

chown owner-user: owner-group file_name

60
Q

displays ip addresses and all the network interfaces

A

ip addr show

61
Q

displays ip addresses of all network interfaces

A

ifconfig

62
Q

retrieves DNS information about a domain

A

dig domain

63
Q

performs refverse lookup on a domain

A

dig -x host

64
Q

performs an ip lookup for the domain name

A

host google.com

65
Q

displays local ip address

A

hostname -i

66
Q

downloads a file from an online source

A

wget file_name

67
Q

displays all active listening ports

A

netstat -pnltu

68
Q

creates archive file called ‘home.tar’ from file ‘home’

A

tar -cf home.tar home

69
Q

extract archive file ‘files.tar’

A

tar -xf files.tar

70
Q

creates gzipped tar archive file from soruce folder

A

tar -zcvf home.tar.gz source-folder

71
Q

compression a file with .gz extension

A

gzip file

72
Q

install source (compliation)

A

./configure
make
make install

73
Q

search for a given pattern in files

A

grep ‘pattern’ files

74
Q

find file names that begin with ‘index’ in /home folder

A

find /home/ -name “index”

75
Q

find files greater than 10000k in the home folder

A

find /home -size +1000k

76
Q

securely connect to host as user

A

ssh user@host

77
Q

securely connect to host using a specified pert

A

ssh -p port user@host

78
Q

securely connect to the system via ssh default part 22

A

ssh host

79
Q

connect to host via telnet default port 23

A

telnet host

80
Q

securely copy file.txt to server2 in /tmp directory

A

scp file.txt server2/tmp

81
Q

synchronize contents in /home/apps directory with /backup directory

A

rsync -a /home/apps /backup/

82
Q

displays free space on mounted systems

A

df -h

83
Q

displays free inodes on filesystems

A

df -i

84
Q

shows disk partitions, sizes, and types

A

fdisk -l

85
Q

displays disk usage in the current directory in a human-readable format

A

du -sh

86
Q

displays target mount point for all filesystems

A

findmnt

87
Q

mount a device

A

mount device-path mount-point

88
Q

displays bootup messages

A

dmesg

89
Q

displays information about systems hardware configureation

A

lshw

90
Q

displays block devices related information

A

lsblk

91
Q

displays pci devices in a tree-like diagram

A

lspci -tv

92
Q

displays usb devices in a tree-like diagram

A

lsusb -tv

93
Q

displays hardware information from the BIOS

A

dmidecode

94
Q

displays information about disk data

A

hdparm -i /dev/xda

95
Q

conducts a read speed test on device xda

A

hdparm -tT /dev/xda

96
Q

tests for unreadable blocks on disk

A

badblocks -s /dev/xda

97
Q

displays information about the user

A

finger username

98
Q

query and change the system clock

A

timedatectl

99
Q

shows system reboot history

A

last reboot