Working with Files
Working with Files
Compress a folder to tar.xz
I came up with this BEFORE tar had the -J option to use XZ compression. This is equivalent though and will also work.
tar -cf - input/ | xz -z -k -6e -T 0 -c -vv - > output.tar.xz
This will run tar on the folder to create a linear archive, then compress that with xz. -T specifies the threads, 0 will use all of them. -6e is the compression. -9 is best, -1 is fastest. Use -6e or anything with e to use more CPU cycles when compressing for marginally better ratio.
7-zip with LZMA2 uses the same compression as XZ. 7-zip is marginally better ratio, but on *NIX systems like Linux, you should use tar.xz since 7zip does not keep file attributes and metadata.
Merge multiple PDF's together
Merging multiple PDF's can be done using several programs. I used to use ImageMagick, but it can destroy the resolution. Instead, ghostscript and pdftk provide nice options.
pdfunite in1.pdf in2.pdf out.pdf
Make sure you put out.pdf otherwise it will overwrite the last file! This has no loss in resolution (unlike the ghostscript version).
Cannot unmount USB drive
If you try unmounting a disk as follows (wherever you mounted it)
sudo umount /run/media/username/FlashDrive
and you get an error umount: target is busy, it can be very annoying to find the process that is using something from the drive.
You can use `lsof` to check which processes are accessing the files.
lsof | grep '/run/media/username/FlashDrive'
This will show you which process is using which file, which can be useful.
Mount NAS storage in fstab
192.168.x.y:sharename /media/yourfolder nfs defaults,nofail 0 0
explanation: ip address, mount point, filesystem, options, order. nofail makes it so the boot can continue even if the mounting fails. This is useful on a laptop and you may not always be connected to your network.
//192.168.x.y/sharename /media/yourfolder cifs auto,nofail,username=user,password=pass,domain=yourdomain,uid=1000,gid=1000 0 0
explanation: smb can have authentication using username and password and domain, they are optional based on if you set up authenticaiton. Without username/password, it will try onnecting as guest. UID and GID are needed so your computer knows who to assign permissions in the mount folder to. Unlike NFS, SMB doesn't report on the file permissions, so if you don't give a uid and gid, you may be stuck and unable to edit files.