-
Notifications
You must be signed in to change notification settings - Fork 0
Filesystem
GradedJestRisk edited this page Nov 21, 2022
·
16 revisions
List:
- add to path
export PATH=$PATH:PATH_TO_ADD
Need | Syntax | |
---|---|---|
Show (physical) location |
pwd -P
|
|
Change owner |
chown OWNER FILE
|
|
Soft link |
ln -s TARGET LINK_NAME (--symbolic)
|
|
Create folder |
mkdir FOLDER_NAME
|
|
Delete file |
rm FILE_NAME
|
|
Delete folder |
rmdir FOLDER_NAME
|
|
Delete folder and contained files |
rm -rf HEAD_FOLDER_NAME
|
|
Find file by name |
find STARTING_PATH -name FILTER
|
Path | Content | |
---|---|---|
/snap | containerized applications | |
/home | user-specific data (not programs) | |
/media | user-specific mounted data (not programs) |
View mount points
# df
or # mount
Mount
Step 1: Get UUID
Input sudo blkid /dev/sda1
Output /dev/md127: LABEL="data" UUID="13f99b52-(..)-a6a47f400303" TYPE="ext4"
Step 2: Mount
# sudo mount --uuid DEVICE_UUID -t TYPE -o OPTIONS DESTINATION_DIR
Unmount
Grateful # sudo umount DESTINATION_DIR -l
Forceful # sudo umount -f DESTINATION_DIR
General:
- list:
-l
(l for list) - sort
- default is alphanumeric, ignoring hidden file dot prefix
- reverse order:
-r
(r for reverse) - by modification time, newest first :
-t
- include hidden files:
- include:
-a
(a for all) - sort them first
LC_COLLATE=C ls -a
- include:
- show file type:
-F
-
/
: directory -
*
: executable -
@
: symbolic link- others (IPC)
-
|
: pipe -
=
: socket -
>
: door
-
- others (IPC)
-
List
- in list
- directories blue and DIRECTORY_NAME/
- readable size
- print only file modification date and file name
- aligned
alias ls='ls -lFh --color=always | awk '\''{print $5,$6,$7,$8,$9}'\'' | column -t'
https://phoenixnap.com/kb/linux-create-partition
List:
- identity your device, eg. sdd
- create partition table on device
- "sudo parted"
- select device: "select /dev/sdd"
- check for existing partition: "print"
- if any partition, remove it using its number: "rm 1"
- create partition table: "mklabel gpt"
- check: print should display "Partition Table: gpt"
- create partition
- "mkpart primary ext4 1MB 1000GB"
- check with "print": ext4 partiton shall exist
- save with "quit"
- create file system
- sudo mkfs.ext4 /dev/sdd1
- check message is "Writing superblocks and filesystem accounting information: done"
- mount
- create mountpoint: mkdir $HOME/mountpoint
- mount read/write for ?: "sudo mount --types auto --options rw /dev/sdd1 $HOME/backup"
- try writing a file: "touch $HOME/backup/test"
- copy files
- cp
- create folder: "sudo mkdir $HOME/backup/2022-11-21"
- copy directory tree: "sudo cp --recursive $HOME/data $HOME/backup/2022-11-21"
- monitor with glances
- give user access to files (current owner is root)
- easy: "chown username $HOME/backup"
- read/write for everyone: "chmod --recursive a=rw $HOME/backup/2022-11-21"
- read/write for specific user: "setfacl --recursive -m u:username:rwx $HOME/backup/2022-11-21"
- tar https://docstore.mik.ua/orelly/unix3/upt/ch10_13.htm
- rsync
- cp