File system Flashcards
What is the find option for selecting files accessed n minutes ago?
-amin n
What is the find option for selecting a file accessed one day or more ago?
find -atime n (where n is n*24 hours ago. -atime +1 is a file that was accessed at least two days ago)
what find option will select a file changed n minutes ago?
find -cmin n
what find option will display the results?
find -print
what is a simple example of find to locate a wild card file name?
find . -name thename*.dat -print
start the search in the current directory .
use the name mask “thename*.dat”
print out the results to the screen
what is a find command to locate all core files and then remove them?
find / -name core -exec /bin/rm -f ‘{}’ \;
start in the root directory
use “core” as the name filter
execute the rm command
force the removal without prompting -f
pass the rm command the file name found ‘{}’ \;
What is the find option for selecting files accessed n minutes ago?
-amin n
What is the find option for selecting a file accessed one day or more ago?
find -atime n (where n is n*24 hours ago. -atime +1 is a file that was accessed at least two days ago)
what find option will select a file changed n minutes ago?
find -cmin n
what find option will display the results?
find -print
what is a simple example of find to locate a wild card file name?
find . -name thename*.dat -print
start the search in the current directory .
use the name mask “thename*.dat”
print out the results to the screen
what is a find command to locate all core files and then remove them?
find / -name core -exec /bin/rm -f ‘{}’ \;
start in the root directory
use “core” as the name filter
execute the rm command
force the removal without prompting -f
pass the rm command the file name found ‘{}’ \;
how do you set the sticky bit on an existing directory structure?
find /path/to/directory -type d -exec chmod g+s {} \;
This will recurse through the entire directory structure settingh the GID on all the directory objects (not the files) to the SETGID of the owner of the parent directory. All files created subsequently, will inherit the same GID of the parent directory instead of the default GID of the user who created the file.
what are the daemons used by nfs?
nfsd
rpcbind
rpc. idmapd
rpc. mountd
rpc. rquotad
rpc. statd
what is the tar command for copying an entire directory tree including the file permissions and links?
tar -cf - {source} | (cd {destination}; tar -xvf -)
Traverse the filesystem just once, listing setuid files and directories into /root/suid.txt and large files into /root/big.txt.
find / ( -perm -4000 -fprintf /root/suid.txt ‘%#m %u %p\n’ ), \
( -size +100M -fprintf /root/big.txt ‘%-10s %p\n’ )
what command will show the server’s current exports?
showmount -e
what command will list the users who have a file open?
lsof {filename}
what command will show the PID of the process that has a file open?
fuser {filename}
what command is used to change the system run level?
init { 0 1 2 3 4 5 6 }
0 — Halt
1 — Single-user text mode
2 — Multiuser but no NFS
3 — Full multi-user text mode
4 — Not used (user-definable)
5 — Full multi-user with X11
6 — Reboot
what command shows the current run level?
who -r
what file defines the default run level?
/etc/inittab
what tools are provided by redhat to configure services?
chkconfig
ntsysv
redhat-config-services
how do you locate all broken symlinks?
find / -name proc -prune -o -name dev -prune -o -type l ! -exec test -r {} \; -print
how do you backup the MBR?
sudo dd if=/dev/sda of=mbr_backup bs=512 count=1
to restore it:
sudo dd if=mbr_backup of=/dev/sda bs=512 count=1
what are the sequence of commands for creating a new partition?
create partition:
parted /dev/sda6 or mkpart for ext3
create filesystem:
mkfs -t ext4 /dev/sda6
*label it: *
e2label /dev/sda6 /work
add to fstab:
LABEL=/work /work ext3 defaults 1 2
**mount it: **
mount /work
what command will show the UUID of the block or disk drives?
blkid
what are the standard default options for fstab?
if the options field ( fourth column ) says “defaults”,
the usual values are:
rw,
suid,
dev,
exec,
auto,
nouser,
async(no acl support)
this can also be tuned with the tune2fs command.
what commands are used to create partitions?
fdisk
sfdisk
cfdisk
parted
what command script string will show all physical drives and their partitions if any?
for disk in ls /dev/sd[a-z]
; do fdisk -l ${disk}; done
what command is used to add a physical volume to a volume group?
vgextend <volgroupname> <pv></pv></volgroupname>
what command is used to remove a pv from a vg?
vgreduce <vgname> <pvname></pvname></vgname>