Skip to content

adamconkey/linux_tips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

Linux Tips

Some things I consistently have to look up how to do. This is mainly a reference for myself to remember how to do certain things in Linux.


rsync

Filter Files and Directories

Here is an example command to transfer files remote host to local by only including directories in the host's /path/to/files directory that have the directory_prefix (and include all their contents) and exclude everything else:

rsync -avW host:/path/to/files/ ./my/local/dir --include 'directory_prefix*/***' --exclude '*'
  • This post gives helpful advice on how to handle --include/--exclude with rsync.

Use a Different Port Number

rsync -e 'ssh -p 5522' -av user@remote:/path/to/transfer ./local/path/to/save/to

Mount a Hard Drive

Manually Mount

  1. Execute lsblk to see what your drive partitions are. Example output:
sda           8:0    0 931.5G  0 disk 
└─sda1        8:1    0 931.5G  0 part /media/data_haro
sdb           8:16   0   3.7T  0 disk 
├─sdb1        8:17   0   200M  0 part 
└─sdb2        8:18   0   3.7T  0 part /media/adam/LL4MA-D2
nvme0n1     259:0    0 465.8G  0 disk 
└─nvme0n1p1 259:1    0 465.8G  0 part /
  1. Create new directory to mount drive to
sudo mkdir /media/data_haro
  1. Mount the drive
sudo mount /dev/sda1 /media/data_haro

Auto-mount at Startup

  1. Install GParted
sudo apt install gparted
  1. Open GParted and select the drive you want to auto-mount. See what it's filesystem type is.
  2. Edit /etc/fstab with root permissions
sudo emacs /etc/fstab
  1. Add a line at the bottom of the file that looks like
/dev/sda1    /media/data_haro    ext4    defaults    0    2
  • First column is drive partition to mount.

  • Second column is mount point.

  • Third column is filesystem type (from GParted).

  • Fourth column is options, leave as defaults.

  • Fifth column leave as 0.

  • Sixth column is fsck which determines filesystem order. Only options are 0 (no check), 1 (check first), and 2 (check second). Only boot should be 1, additional drives should be 2.

  • Ubuntu: Mount The Drive From Command Line - Simple instructions for mounting a hard drive manually and setting up fstab to auto-mount on startup.

You may need to change the permissions on the drive:

sudo chown -R username:username /media/data_haro

where you should set username to be your username.

Note if you do the auto-mounting and then decide to remove the drive, you must comment out the entry in /etc/fstab. Otherwise you may find yourself unable to boot the OS and enter emergency mode like described here.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published