understand and use essential tools Flashcards

Understand and use essential tools

1
Q

Virtual Console or tty

A

Ctrl + alt + F1 through F6.

Ctlr + alt+ F7 will bring back the GUI

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

cat example

A

cat &laquo_space;EOF > file1

> this is the content
of file 1
EOF

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

cat example 2

A
#cat > file1
this is the content of file1
^d^d(ctrl+d stop entry)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

grep examples

A
#grep --color 'root' /etc/passwd
#grep -i 'root' /etc/passwd      matches case insensitive
#grep -v 'root' /etc/passwd     matches everything but root
#grep -n [Aa] text.txt     matches upper and lower case
#grep '^root' /etc/passwd   starts with rootgrep 'root$' /etc/passwd   end with root
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

generate ssh key

A

use the ssh-keygen command

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

create a tarball example

A

tar -cvf data.tar dataDir

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

gzip tar file/directory

A

gzip data.tar creates data.tar.gz

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

bzip tar file/directory

A

bzip data.tar creates data.tar.bz2

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

tar with gzip file/directory

A

tar -czvf data.tar.gz dataDirtar -czvf data.tgz dataDir

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

tar with bzip2 file/directory

A

tar -cjvf data.tar.bz2 dataDir

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

extract tar.gz

A

tar -xzvf data.tar.gz

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

extract tar.bz2

A

tar -xjvf data.tar.bz2

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

Main Tar command options

A

c(create an archive), x(extract an archive), t(test or list the contents of an archive)

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

Other tar command options

A

v(verbosity), f(filename), z(for gzip), j(for bzip2)

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

bzip to uncompress files

A

bunzip abc.tar.bz2

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

gzip to uncompress files

A

gunzip2 etc.tgz

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

Star command

A
More appropriate for archiving files in a SELinux System. It's not installed by default:
# yum install star
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Star command to archive a file

A

star -xattr -H=exustar -c -f=home.star /home

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

star more example to compress a file/directory(ies)

A

star -cv f=archive2.star test-dir

star -xattr -H=exustar -c -f=files.star file{1,2,3}

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

Star extract file/directory(s) example

A

star -xv f=/tmp/archive2.star

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

star list files in an archive file

A

star -tv f=/tmp/archive2.star

22
Q

Text editors

A

Vi(Preferred)
gedit(GUI)
nano(text editor)

23
Q

Create a hard link

A

ln filetolink desktop/file

24
Q

Create a symlink

A

ln -s filetolink desktop/filelink

25
Q

To view inode #

A

ls -li file

26
Q

Hard link

A

a pointer to a file’s inode

27
Q

soft link (symlink)

A

a pointer to a file

28
Q

Linux ugo/rwx permissions

A

read (r)
write(w)
execute(x)

29
Q

Octal value for permission bit

A
read = 4
write = 2
execute = 1
No permission(or dash "-") = 0
30
Q

Umask command

A
The default permission in RHEL comes from the umask or user file creation mode mask value. run the umask command to see your default umask value:
# umask
31
Q

Umask value obtained

A

From the /etc/profile script

32
Q

File default umask

A

666

33
Q

Directory default umask

A

777

34
Q

Calculate umask of a file

A

subtract default file umask (666) from current user’s umask(0022) = 0644

35
Q

Calculate umask of a directory

A

subtract default directory umask(777) from current user’s umask(0022) = 0755

36
Q

set the immutable bit

A

chattr +i file

37
Q

view attributes of a file

A

lsattr file

38
Q

immutable bit

A

It helps prevent accidental deletion. Review man 1 chattr to learn more attributes which can be applied to a file

39
Q

attributes that can be added to a file

A

(acdeijstuADST), a = append only, c = compressed, d = no dump, e = extent format, i = immutable, j = data jornaling, s = secure deletion, t=no-tail-merging, u = undeletable, A = no atime updates, D = synchronous directory updates, S= synchronous updates, T = top of directory hierarchy.

40
Q

chattr options

A
  • R = recursively
  • V = verbose
  • f = suppress most error messages
  • v = set the file version(generation number)
41
Q

Managing Permissions from gui

A
You can use the Nautilus file management tool-- right click on a file or folder > select properties > click on the permission Tab.
 -- Or launch Nautilus from the command line:
# Nautilus &
42
Q

Special permissions

A

Setuid or setgid permission of an executable means that the command will run as the user(or group) of the file, not as the user that ran it.The sticky bit for a directory sets a special restriction on deletion of files: only the owner of the file and root can delete within the directory, example is /tmp

43
Q

special permissions effect on files

A

U+s (SUID) - file executes as the user that owns the file, not the user that ran the file.
G+s(SGID) - file executes as the group that owns the file. o+t(sticky) - no effect on file

44
Q

Special permissions effect on directories

A

U+s(SUID) - no effect on directory
G+s(SGID) - files newly created in the directory have their group owner set to match the group owner of the directory.
O+t(sticky) - users with write on the directory can only remove files that they own, they cannot remove files owned by other users

45
Q

Setting special permissions

A
Symbolically: setuid = u+s, setgid = g+s, 
sticky = o+t
Numerically: (fourth preceding digit) setuid = 4; setgid = 2; sticky = 1.
# chmod 4770 file
# chmod 2770 dir
# chmod g+s dir
46
Q

to search for unknown man pages

A
# man -k lvm
# apropos lvm
# whatis nfs
or you can run ls on /usr/share/doc
47
Q

no output from man pages

A
First check for the package
# rpm -qa man    then if it's installed run:
# makewhatis &
48
Q

info pages

A

Similar to man pages
# info -k lvm
info pages are located in /usr/share/info

49
Q

Man pages sections and meanings

A

1 ———– user commands
2 ———- Kernel System calls (entry points to the kernel from userspace)
3 ———- Library functions
4 ———- Special files and devices
5 ———- file formats and conventions
6 ———- Games
7 ———- Conventions, standard, and miscellaneous pages
8 ———- System administration commands
9 ———- Linux kernel HPI (internal kernel calls), this is recent

50
Q

Access remote system using VNC

A

$ yum install tigervnc-server This puts a config file on your remote machine in /etc/sysconfig/vncservers
edit this file and add:
VNCSERVERS=”2:myusername”VNCSERVERARGS[2]=”-geometry 800x600 -nolisten tcp -nohttpd”
Aside from changing “username” you want it to look like this. All we did to change it, is remove the “-localhost” directive. This would have restricted us from connecting from a remote system without a tunnel setup. Since this is an exam and not the real world, we can disable that.
Set up your password on the remote machine by running
$ vncpasswd
And finally start your vncserver
$ vncserver :1
The output should look like this:
[root@rhel6 ~]# vncserver :1 New ‘rhel6.local:1 (root)’ desktop is rhel6.local:1 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/rhel6.local:1.log
The default vnc client on Red Hat Enterprise Linux 6 is tigervnc. If it is not already installed on the system:
$ yum install tigervnc
To connect to the newly setup vncserver just type:
$ vncviewer rhel6.local:5901(replace rhel6.local with your remote host)