linuxacad Flashcards
what are the two commands for uncompressing a file?
gzip -d (for decompress) or gunzip
what tar command will show what is in the archive and compare it to the destination of an extract?
tar -dvf mytarfile (the d does a diff without extracting)
what command can be used to expand an archive without overwriting any destination files?
star -x -f=myarchive.tar
star is not a default installed file. yum install star will install it.
what commands would make a change and put into effect a change to the sshd configuration?
vim /etc/sshd/sshd_config
systemctl restart sshd
what port does ssh use?
22 with encryption
what syntax is used by scp to specify a remote file and the user id to copy it with?
username@hostname:filename
root@rx1-tec-stc:~/Utilities/tmp/get_all_robot_probes.csv
what key stroke allows searching the command history?
ctrl-r then start typing the command for automatic completion.
what command logins in and runs the login shell for root?
su - root
su –login root
su -l
or just su -
what command logs in but does not execute the login shell for root?
su (with no parameters)
what file is loaded and run when a user logs in with the login shell?
~/.bash_profile
what file is a login script for all users?
/etc/profile
how do you specify the destination file for an archive file?
tar -cvf myarchive.tar filetoadd1 filetoadd2 directorytoadd/
what command will show the contents of an archive file?
tar -tf myarchive.tar
what command will create an archive with gzip compression?
tar -cvzf myarchive.tar.gz (the z would compress and create a compressed file with gzip)
what command will create an archive with bzip compression?
tar -cvjf myarchive.tar.bz (the j would compress and create a compressed file with bzip)
what command shows how existing files have been changed since they were added to an archive file
tar -dvf myarchive.tar
what command would take away the write permission on a file for the owner of the file?
chmod u-w myfilename
what command would use chown to change the group owner on a file or directory?
use a colon to designate the group name value
chown :mygroupname myfilename
how do you set group permissions for a directory tree recursively?
chmod g+w -R mydir
what command would remove execute privileges on files but still allow access to directories recursively?
chmod ug-X -R mydir (the capital X does it)
what command would change the privileges on user, group and other at the same time?
chmod a+w myfilename
would grant write priveleges to user group and other
what does the sticky bit do and what does it look like?
allows a program to be run with the same privileges as the owner (or the group owner) of the file.
ls -la myfile
-r-sr-sr-x myfile
how do you set the setuid bit on a file using octal notation?
chmod 4500 (4 = set user sticky bit 2 = set group sticky bit or 6500 set user and group sticky bit on)
what would prevent accidental deletion of a file even if they own the file?
setting the sticky bit on the “other” on a file:
chmod -t myfilename
r-s r-s r-T root root myfilename
the T means others can read it but the user cannot delete it.
what is the default umask setting?
0022
default file perms are always 666. if the umask is 2 then subtract 2 from 6 you get 4 which means set r read but not write or x. as in r–
where is the default setting for umask set for all users?
/etc/bashrc for all shells started
/etc/profile for all login sesisons started
what creates a man page index?
mandb
Once indexed, then you can use the command apropos to find all topics using a key word.
what key in the info tool will show the navigation keys?
the question mark: ?
where are the info files stored?
/usr/share/info
what command would show all info pages related to the key word tee?
info –apropos tee
what command can show the directory location of a command executable?
locate mycommandname
what command would refresh the search of the locate command?
updatedb
usually run by cron every day
what command will search man pages based on the entries description phrase?
whatis mycommandname
what command would install the locate command?
What does the locate command do?
yum install mlocate
the locate command creates a cached DB containing the location of files found
what command updates the cache for the locate command?
updatedb
what command would reboot a machine in 5 minutes and tell all logged in users that?
shutdown -r +5 System reboot will happen in 5 minutes.
what command will stop a system reboot before it begins?
shutdown -c
how do you schedule a reboot?
shutdown -r 00:00
reboot at midnight (24 hour values)
what command would shutdown or power down a system?
systemctl halt
or
halt
in what directory are the system state targets located?
/user/lib/systemd/system
what command will show the available system states?
systemctl list-units –type=target
what command would show the dependencies on the multi-user target?
systemctl list-dependencies multi-user.target
what command shows the current run level?
systemctl get-default
what target enters a read only file system state?
emergency.target
what target enters a single user mode env for system recovery?
rescue.target
how do you set the default target run level to multi user mode?
systemctl set-default multi-user.target
how to you get to an special run mode for a system having trouble booting up?
interupt grub start (move the arrow keys for the menu)
select the default menu item
press ‘e’ to edit
find the linux16 line
at the end of that line add: system.unit=rescue.target
press Ctrl-x to move on in the boot mode into the rescue mode
what command in the grub menu config would enable entering into the initfms system?
rd.break ( at the end of the linux16 line in the grub menu config line )
what commands are needed in the initfs ram mode to modify configurations or correct a system problem before the system boots up into the kernel? Say to reset the root password if it is not known.
do an rd.break in the grub menu then ctrl-x
mount -oremount.rw /sysroot ( make the current system root directory read write )
chroot /sysroot ( change the system root directory from sysroot to /root )
passwd to change the current root password
touch /.autorelabel ( to force a relabel during the next boot up and relabel all files after making a change to the passwd file )
what command shows the available signals for kill?
kill -l ( for list )
what is the default signal issued by the kill command?
sigterm or kill -15 ( number for sigterm )
what kill command is the same as a ctrl-C?
sigint or kill -2 ( user keyboard interupt )
what command stops or pauses a process and then starts it again?
kill -19 ( sigstop )
kill -18 ( sigcont )
what command would show the process id, command, and nice level?
ps axo pid,comm,nice
what command would start a process and set the priority level of a process to zero and what is the priority range available?
nice -n 0
lowest priority is 20 up to highest priority -20
what command would change the priority of all httpd running processes?
renice -n 10 $(pgrep httpd)
what do the load average numbers shown with the top or uptime comands mean?
av for 1 minute, 5 minutes, 15 minutes
load average: 0.07, 0.58, 0.91
percentage of cpu processor used on average for each time period for the total number of processors (7% 58% and 91%). If there are 2 CPU’s then the usage is 7% divided by 2.
what shows the number of cpu’s on a system?
cat /proc/cpuinfo | grep “model name” | wc -l
what command will change the update interval for top?
top -d 1 for update every second
What command controls the contents of the system messages log file?
journalctl
where are the journald messges stored?
/run/log/journal
it is not persistent. Gets cleaned out during each reboot
how do you make the journald messages persistent between reboots?
vi /etc/systemd/journal.conf
uncomment the line #Storage=auto and change it to Storage=persistent
restart the systemd service
changes the storage location from /run/log to /var/log
what determines what log files are being updated and where they are located?
rsyslog
/etc/rsyslog.conf
Whatcommand will display available systemd unit types?
systemctl -t help
What command will create or update the manual page index caches; something you should run after installing new man pages?
mandb
how many partitions can there be in the mbr partitition and what is the bit size basis?
only 4 partitions of 2 TB each because it is based on 32 bit math.
what command in fdisk will show the available commands?
m for menu
what is the replacement for mbr type partitioning and what features does it add to partitioning?
gpt it is 64 bit based instead of 32 bit can accomodate more that 4 primary partitions up to 128 partitions on a single devise partitions can be larger that 2 GB
what are the steps for adding an mbr partition and mounting it?
fdisk /dev/{device name}
n (for new)
p (for primary partition type or e for extended)
1 (for partition number)
+{number}M (for the next {number} megs of space)
l (for list available partition labels)
t (for change the partition system ID or type of partition)
w (for write the changes selected)
mkfs -.t xfs {device name}
blkid (to see the available block storage systems)
cd /mnt
mkdir {mountpoint}
mount /dev/{device name} /mnt/{mountpoint}
what is the sequence for creating a logical volume?
create the paritions with gdisk using the LVM label type
create physical volumes with pvcreate (pvdisplay to see it)
create logical volume groups with vgcreate
create logical volume device with lvcreate
create partitions and mounts as usual
What will create a new block device from existing block devices on an xfs file system device?
xfs_admin -L filesystem1 /dev/xvdfs1
what will create a new block device on an ext4 block device?
tune2fs
what are the fields in the fstab file for?
1 (fs_spec), describes the block special device or remote filesystem to be mounted.
2 (fs_file), describes the mount point for the filesystem. For swap partitions, this field should be specified as none.
3 (fs_vfstype), describes the type of the filesystem.
4 (fs_mntops), describes the mount options associated with the filesystem.
5 (fs_freq), is used for these filesystems by the dump(8) command to determine which filesystems need to be dumped.
6 (fs_passno), is used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time.
example:
/dev/mapper/vg_redweb-lv_root / ext4 defaults 1 1
UUID=68fed9db-aa05-4f03-885f-1daceb6ba6d3 /boot ext4 defaults 1 2
/dev/mapper/vg_redweb-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
how do you create a swap mount?
mkswap (NOT mkfs)
what command will temporarily mount a swap disk?
swapon /dev/{devicename}
best to define it in fstab for permanent enabling between boots
what command shows all the available block devices?
blkid
/dev/mapper/vg_redweb-lv_root: UUID=”205fb472-18ac-4e0a-85c6-592a4f064372” TYPE=”ext4”
/dev/sda1: UUID=”68fed9db-aa05-4f03-885f-1daceb6ba6d3” TYPE=”ext4”
/dev/sda2: UUID=”HP3yRX-KicC-U1mi-7l26-cgrf-l9Ck-ywncc0” TYPE=”LVM2_member”
/dev/mapper/vg_redweb-lv_swap: UUID=”a54bf4aa-4b79-4605-89c2-4c7542fc9ab7” TYPE=”swap”
what command will show all the existing swap being used by the linux memory manager?
swapon -s
After adding 50GB more of physical storage to your existing volume group, you need to extend your /dev/battlestar/galactica volume group to include an additional 20GB of storage. How might you accomplish this task?
lvextend -L +20G /dev/battlestar/galactica
Which file on the operating system contains information about partitions the OS is reading?
cat /proc/swaps
Which command is used to assign a swap signature to a device?
fdisk or gdisk
What command(s) is used to inform the OS of partition table changes?
partprobe
What are two ways to find information about swap devices enabled on the system?
swapon -s
cat /proc/swaps
After making partition changes, the partition changes do not appear in the /proc/partitions. How can you force the kernel to reload the partition tables?
issue the partprobe command
You are extending a logical volume. In order to do this, you have to add the /dev/xvdj device to the volume group “battlestar”. What command would you issue in order to accomplish this task?
vgextend battlestar /dev/xvdj
Given the volume group “battlestar” and a physical volume in the volume group “/dev/xvdf1”, which command would accurately create a 19G logical volume out of /dev/xvdf1 with a volume name of “galactica”?
lvcreate –size 19G –name galactica /dev/xvdf1
check this
What is the maximum disk size for a GPT based partition
GPT allocates 64 bits for logical block addresses, maximum size is 9.4 ZB or 8 ZiB
Which command is used to assign a swap signature to a device?
mkswap
You’ve just increased the size of the /dev/battlestar/galactica LVM volume. This volume is mounted in /mnt/mydir; what commands would you issue in order for the operating system and files system to recognize the increase in size on the device?
xfs_growfs /mnt/mydir
Which tool(s) would you use to mange GPT based partitions?
gdisk
parted
For an MBR partition, what is the max disk size a partition can be?
2TiB
You are extending a logical volume. In order to do this, you have to add the /dev/xvdj device to the volume group “battlestar”. What command would you issue in order to accomplish this task?
vgextend battlestar /dev/xvdj