Cheatography
https://cheatography.com
Commands used for file management in Linux
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Basic File Management
cp file name [-r creates destination] |
mv Linux Command Cheatsheet to Linux |
| is also for renaming |
add -i, -n or -v |
| ask first, no overwrite, show result |
cat filename |
| opens the file to read |
less |
| breaks results down into pages |
mkdir\rm directory |
rm |
cd |
touch |
| creates a new file |
Listing Files
-h |
| human readable |
-d |
| lists the details |
-R |
| recursive [all sub-directories] |
-s |
| sorts by name |
-t |
| sorts by time |
Working with File Permissions
chmod 777 [name of file] |
| assign read, write & execute to all users |
chmod 755 [name of file] |
| read, write & execute for owner - read & execute for all other users |
chmod 766 [name of file] |
| full permission to owner - read and write to others |
|
chown |
| change ownership |
|
[OPTIONS] [OWNER] FILE |
File Compression
gzip |
| common compression tool |
gunzip |
File Archiving
tar –cvf mybackups/udev.tar /etc/udev |
-c option tells the tar command to create a tar file.
-v option stands for "verbose", which instructs the tar command to demonstrate what it is doing.
-f option is used to specify the name of the tar file.
Review Archive Contents
tar –tvf mybackups/udev.tar |
Create a Compressed Archive
tar –zcvf mybackups/udev.tar.gz /etc/udev |
| create an archive |
tar –xvf udev.tar.gz |
| extract an archive |
tar -rvf udev.tar /etc/hosts |
| add a file to existing archive |
|
|
File type descriptors
Symbol |
File Type |
Description |
d |
| directory |
| A file used to store other files. |
- |
| regular file |
| Includes readable files, images files, binary files, and compressed files. |
l |
| symbolic link |
| Points to another file. |
s |
| socket |
| Allows for communication between processes. |
p |
| pipe |
| Allows for communication between processes. |
b |
| block file |
| Used to communicate with hardware. |
c |
| character file |
| Used to communicate with hardware. |
File Type
- rw-r--r-- 1 root root 15322 Dec 10 21:33 alternatives.log |
d rwxr-xr-x 1 root root 4096 Jul 19 06:52 apt |
Permissions
d rwxr-xr-x 2 root root 4096 Jul 19 06:51 journal |
Hard Link Count
-rw-r----- 1 syslog adm 371 Dec 15 16:38 auth.log |
drwxr-xr-x 2 root root 4096 Jul 19 06:51 journal |
User Owner
-rw-r----- 1 syslog adm 197 Dec 15 16:38 cron.log |
Group Owner
-rw-rw-r-- 1 root utmp 292584 Dec 15 16:38 lastlog |
Timestamp
-rw-rw---- 1 root utmp 0 May 26 2018 btmp |
File Size
-rw-r----- 1 syslog adm 14185 Dec 15 16:38 syslog |
Displays the size of the file in bytes.
File Name
-rw-r--r-- 1 root root 35330 May 26 2018 bootstrap.log |
In the case of symbolic links, the link name is displayed along with an arrow and the pathname of the original file.
lrwxrwxrwx. 1 root root 22 Nov 6 2018 /etc/grub.conf -> ../boot/grub/grub.conf
|