Linux Up Skill Challenge 03

Wow here we are on week 3 of the r/linuxupskillchallenge.

I will admit I did not keep up to date with my blogs of the course, so I am retroactively covering the material again to not only remember more but also update the log posts.

Day 11 – Finding things

We have a few options/tools to find/search linux such as:

  • which nano, or which vim -> useful for tell you the path of a program
  • find /var -name access.log
  • find /home -mtime 3 -> finds the files within the last 3hours
  • locate access.log -> is very quick because it uses a database of the entire system so make sure you have recently run sudo updatedb
  • grep - R -i "PermitRootLogin" /etc/* -> grep Recursive with case insensitive

consider even piping them together find /var -name access.log 2>&1 | grep -vi "Permission denied"

Day 12 – Copying with SFTP

Ok, today really blew me away. I have used SFTP before whilst setting up a Wireguard VPN on my raspi but I am at my core a sucker for a good UI, and discovering the fact that you can use STFP to directly connect to a system like a network drive/hdd in Nemo (on linux mint) made me very happy. 🙂

You may have heard of FTP or File Transfer Protocol well SFTP is pretty much the same thing except that it works over the SSH protocol (sort of). It is great for security because more than likely you will already be accessing your machine via SSH, so there is no need to open another port just to use FTP for example.

Once you log in to you machine with sftp username@servername you must now be aware of the fact that your machine is LOCAL and the server is REMOTE. What this means is that commands like pwd now work on the remote machine, however putting an l in front (lpwd) runs the command locally.

  • cd dir -> Change directory on the ftp server to dir.
  • lcd dir -> Change directory on your machine to dir.
  • ls -> List files in the current directory on the ftp server.
  • lls -> List files in the current directory on your machine.
  • pwd -> Print the current directory on the ftp server.
  • lpwd -> Print the current directory on your machine.
  • get file -> Download the file from the ftp server to current directory.
  • put file -> Upload the file from your machine to the ftp server.
  • exit -> Exit from the sftp program.

What I loved in Nemo on linux mint is the ability to in the UI go to File > Connect to Server bang in your SSH details and just like that the remote machine appear like a mounted drive. Now working with the files on the remote machine is all GUI based 😉

Lets have a look at rsync. Rsync has many features but a very useful one is that it lets you just copy files that have changed since the last time you ran rsync.

  • rsync -e "ssh username@servername" -av localdir/ :remote_dir
  • a = archive, v = verbose, r = recursive, u = update the files, P = show Progress of transfer
  • --dry-run is also handy to see what it is going to change.

be aware of the slash on localdir/ this sends the files within this directory. If we remove the / we will send all the files inside the localdir and the directory itself.

Leave a comment