click below
click below
Normal Size Small Size show me how
Files Directories
Miscellanious
Question | Answer |
---|---|
Directs the standard o/p to the /tmp/deleteme file , then directs the standard error messages be sent to the same place as the standard o/p. Both the list of files in the /bin directory and the error message are written to the file | ls /bin /nonesuch > /tmp/deleteme 2>&1 |
Write the contents of the /bin directory to the /tmp/deleteme file, error message '/nonesuch not found' to the screen, because standard error messages are directed to the same place standard o/p before standard has been directed to the file | ls /bin /nonsuch 2>&1 /tmp/deleteme |
Reads items from standard input and breaks up long lists of arguments into smaller, usable lists | xargs |
Overcomes a 128 KB shell command size restriction in older Linux kernels - and commonly takes input from: find, ls, locate, and grep -l | xargs |
xargs Options: Ignore space names in files | find / -print0 -name *.odt | xargs -0 rm |
xargs Options:Replace the initial argument of a command with the argument from the standard input | xargs -l |
Find all the .jpg files on te computer and copies them into the /home/usr/Pictures directory | find / -name `*.jpg` | xags -l var1 cp var1 /home/usr/Pictures |
Takes input from the unordered _file.txt file and sends it to the SORT command and then writes a new file named ordered_file.txt | sort < unordered_file.txt > ordered_file.txt |
ls Option: list in reverse order | ls -r |
mv Options: Overwrites directory that already exists in the destination directory | mv -f |
mv Options: Prompt before overwriting a directory in the destination directory | mv -i |
mv Options: Never overwrite files in the destination directory | mv -n |
Move or rename directories and files. Moving directories erases the source directory and places it in the destination | mv |
Delete an EMPTY directory | rmdir |
Delete directory, sub-directories and files without prompting | rm -rf |
Directory contains binary commands that are available to all users | /bin |
Directory contains the kernel and bootloader files | /boot |
Directory contains device files that represet the devices used by the system , such asa hard-drive, mouse, and printer | /dev |
Directory contains configuration files specific to the system | /etc |
Directory contains by default the user home directories | /home |
Directory contains shared program libraries and kernel modules | /lib |
Directory contains the /cdrom and /floppy directories | /media |
Directory is an empty directory, and often used for temporarily mounted filesystems | /mnt |
Directory contains the additional programs on the system | /opt |
Directory is the root user's home directory, Not to be confused the the root of the system (/) | /root |
Directory contains information about the system's state and processes | /proc |
Directory contains system binary commands | /sbin |
Directory contains files for servers such as HTTP and FTP servers | /srv |
Directory contains the sysfs virtual file system which displays info about devices and drivers | /sys |
Directory contains temporary files created by programs during system use (should be periodically cleared - have its own partition) | /tmp |
Directory contains system commands and utilities | /usr |
Directory contains data files that change constantly (volatile) | /var |
/var Sub-directory: holds email in boxes | /var/mail |
/var Sub-directory: holds files waiting for processing, such as print jobs or scheduled jobs | /var/spool |
/var Sub-directory: holds www or proxy cache files | /var/www |
List the FIRST 10 lines of a file (default). | head |
List the first 20 lines of the /home/myfile file | head -n 20 /home/myfile |
List the LAST 10 lines of a file (default) | tail |
List the LAST 20 lines of the /home/myfile file | tail -n 20 /home/myfile |
List all lines of the /home/myfile EXCEPT the first 15 line | tail -n -15 /home/myfile |
Display the file TYPE - shows whether the file is a text,data, xml, or other type of file | file |
File uses signatures in: | /usr/share misc/magic /usr/share/misc/magic.mgc /etc/magic |
cp Options: Overwrites files that already exist in the DESTINATION directory | cp -f |
cp Options: Prompts before overwriting a file in the DESTINATION directory | cp -i |
cp Options: Update the existing DESTINATION file | cp -u |
cp Options: Create a HARD LINK rather than copying a file | cp -l |
cp Options: Create a SYMBOLIC LINK rather than copying a file | cp -s |
cp Example: Create a symbolic linked named /home/myfile that points to /home/text_link | cp -s /home/myfile /home/text_link |
ln Options: Create a backup of a file | ln -b |
ln Example: backup /home/asmith/myfile to /backup - copy myfile as myfile in /backup | ln -b /home/asmith/myfile /backup |
Derlates a file and overwrites the file information | shred |
shred Options: Specify the number of times to overwrite -default is 25 | shred -n |
shred Options: delete the inode | shred -u |
shred Options: display progress (Verbose) | shred -v |
shred Options: Overwrite the FILENAME with zeros | shred -z |
shred Example: Deletes the companyplan.txt file and overwrites the file with random information, then leave zeros in place of the file | shred -u -z companyplan.txt |
List file ATTRIBUTES | lsattr |
lsattr Options: Recursively list attributes of directories and their contents | lsattr -R |
lsattr Options: Display the program version | lsattr - V |
lsattr Options: List all files in directories | lsattr -a |
lsattr Options: List directories like other files, rather than listing their contents | lsattr -d |
lsattr Options: List the file's version/generation number | lsattr -v |