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
find all instances of file
locate $locate file
26
halts current command
ctrl + c
27
stops current command
ctrl + z
28
brings most recent job to foreground
fg
29
lists stopped/bacgkround jobs, resume stopped job in the background
bg
30
log out of current session
ctrl + d
31
erases one word in current line
ctrl + w
32
erases whole line
ctrl + u
33
reverse lookup of previous commands
ctrl + r
34
list of commands used
history
35
repeat last command as root
!!
36
log out of current session
exit
37
brings job n to foreground
fg n
38
displays the details of the active user e.g. uid, gid, and groups
id
39
shows the last logins in the system
last
40
adds the group 'admin'
groupadd "admin"
41
adds the user sam
adduser "sam"
42
delets user sam
userdel "sam"
43
forcefully removes a file
rm -f filename
44
removes a directory recursively
rm -r directory_name
45
encripts a file
gpg -c file_name
46
decrypts a file
gpg file_name.gpg
47
executes commands from standard input
xargs
48
lists files that are open by processes
lsof
49
find firefox process ID
pgrep firefox
50
visualizing processes in tree model
pstree
51
kills/terminates all processes named proc
killall proc
52
terminates process with a given pid
kill pid
53
displays all running processes
top
54
displays memory map of processes
pmap
55
searches for the id of the process "telnet"
ps aux | grep "telnet"
56
sts rwx for owner, rw for group and everyone
chmod 766
57
sets rwx to owner and r_x to group and everyone
chmod 755
58
sets rwx permissions to owner, group, and everyone (everyone else who has access to the server)
chmod 777
59
change owner and group owner of the file
chown owner-user: owner-group file_name
60
displays ip addresses and all the network interfaces
ip addr show
61
displays ip addresses of all network interfaces
ifconfig
62
retrieves DNS information about a domain
dig domain
63
performs refverse lookup on a domain
dig -x host
64
performs an ip lookup for the domain name
host google.com
65
displays local ip address
hostname -i
66
downloads a file from an online source
wget file_name
67
displays all active listening ports
netstat -pnltu
68
creates archive file called 'home.tar' from file 'home'
tar -cf home.tar home
69
extract archive file 'files.tar'
tar -xf files.tar
70
creates gzipped tar archive file from soruce folder
tar -zcvf home.tar.gz source-folder
71
compression a file with .gz extension
gzip file
72
install source (compliation)
./configure make make install
73
search for a given pattern in files
grep 'pattern' files
74
find file names that begin with 'index' in /home folder
find /home/ -name "index"
75
find files greater than 10000k in the home folder
find /home -size +1000k
76
securely connect to host as user
ssh user@host
77
securely connect to host using a specified pert
ssh -p port user@host
78
securely connect to the system via ssh default part 22
ssh host
79
connect to host via telnet default port 23
telnet host
80
securely copy file.txt to server2 in /tmp directory
scp file.txt server2/tmp
81
synchronize contents in /home/apps directory with /backup directory
rsync -a /home/apps /backup/
82
displays free space on mounted systems
df -h
83
displays free inodes on filesystems
df -i
84
shows disk partitions, sizes, and types
fdisk -l
85
displays disk usage in the current directory in a human-readable format
du -sh
86
displays target mount point for all filesystems
findmnt
87
mount a device
mount device-path mount-point
88
displays bootup messages
dmesg
89
displays information about systems hardware configureation
lshw
90
displays block devices related information
lsblk
91
displays pci devices in a tree-like diagram
lspci -tv
92
displays usb devices in a tree-like diagram
lsusb -tv
93
displays hardware information from the BIOS
dmidecode
94
displays information about disk data
hdparm -i /dev/xda
95
conducts a read speed test on device xda
hdparm -tT /dev/xda
96
tests for unreadable blocks on disk
badblocks -s /dev/xda
97
displays information about the user
finger username
98
query and change the system clock
timedatectl
99
shows system reboot history
last reboot