Let’s Play Around With The ‘MV’ Command

Today, we’re going to play with the ‘mv’ command, just as the headline implies. It’s a pretty easy command for anything you’re likely to do with it, and it’s a great way to accomplish some pretty neat things in the terminal.

So, let’s start with the ‘mv command. Right away, when we check the man page, it shows you one of its greatest features. It defines itself as:

mv – move (rename) files

And right away you see that it does more than just move files. It also seems to be a command that newer folks don’t use. Maybe they’re afraid of it? Maybe it just doesn’t get enough love? I dunno, but I know it’s a pretty great command. This article is gonna cover it.

Let’s mix things up a little! Why don’t you open your terminal and we’ll start from the same page. Enter the following commands into your terminal, one after the other, pressing enter between each one.

Now, assuming I’ve done that properly and you’ve followed along, you should have made some files, a couple of directories, and your ‘pwd‘ (print working directory) is ~/Documents/tmp.

See? Now we’re all on the same page, and this is a fine time to start an article about the ‘mv’ command!

Play With The ‘MV’ Command:

So, for once, I don’t have to start this section by telling you how to open your terminal! You should have it open from the preparation we did in the intro! That’ll save some time…

So, with that terminal open, I want you to enter the following:

That should move the ‘file1.txt’ to the test directory. If you want to actually verify this, just go like:

Which should show you that the file has in fact been moved. Let’s go back to that same tmp directory and verify that it’s no longer there.

And you’ll see that file1.txt is no longer there in the tmp directory. And, seeing as you’re back in the right directory, let’s rename a file using the ‘mv’ command. Try this:

This will have renamed the file2.txt to changed.txt and you can once again verify that the former has been renamed to the new filename changed with the ls command.

Finally, with one more trick up its sleeve, you can both change the name and move the file at the same time. To do so, you’d just go with:

If you then run ls in both the pwd and test directory, you’ll see all the changes have been made, exactly as intended. If you need to, open your graphical file manager and verify it visually, but you can just as easily use the ls command and verify it all.

For fun, if you want to delete all those, you can move to the ~/Documents directory (cd .. or cd ../..) and use this command:

That’ll clean up any sign that we’d been there and done this exercise. There’s more to the ‘mv’ command and, as always, be sure to check the man page for more usage instructions (to learn things like the -f switch). But, these are the most common ways you’ll use the ‘mv’ command and I wanted you to have a basic familiarity with it.

Closure:

And there you have it… It’s something a little different, as I felt it important that we start from the same place. I also figured I’d try a little bit of a different writing style for this one. If I can’t have fun, why do it? Either way, it’s yet another article. It’s one step closer to the year-long commitment I’ve made. (It’s gonna be a long year.)

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Guest Article: What Are SSH Keys?

The following article is a guest-written article from Andy Brooks (aka captain-sensible) about SSH keys. So, let’s put our hands together for a guest author and appreciate that I got a break from writing articles! Thanks, Andy!

There are a few articles about SSH already:

Install SSH to Remotely Control Your Linux Computers
Enable x11 Forwarding With SSH (Remotely Use GUI Applications)
How To: Change The Port SSH Uses

What Are SSH Keys?

Recently, I created an account for the AUR (Arch user repository) with a view to taking over an maintaining an Aurphan AUR package. On the registration form, which included the usual user name etc, was a text box asking for my SSH public key? You might wonder what is that, why do the AUR want it, and how are they going to use it?

Well the AUR would hold my public key and that would be associated with my user account. What I would want to do with the AUR for a package would be update the PKGBUILD file and get those changes published on AUR repository. So basically that would require getting access to the server of the AUR by logging in and then pushing up my changes to it.

So how are SSH keys involved in that process ? Well on my PC in my home folder there is a directory called .ssh inside are two text files called id_rsa id_rsa.pub. The information held inside the id_rsa.pub, the AUR has a copy of.

If and when I access AUR to make changes, to any package on the repo, there is an exchange of information over my terminal that I am using as a communication channel via ssh. The server sends a challenge, which is to see if my private key matches up with the public key which the AUR server is holding a copy of.

A couple of points are the process involves encryption and the only key that should be “given out” to anybody is the public key. The private key should be, well kept private and out of peoples hands. Putting it simply, ssh-keys are a way of securely giving users access to remote servers. Secure Shell was created in 1995 by Tatu Ylönen a Finnish national following a password-sniffing attack at his university.

Now for registration for accounts such as with the AUR, there are really only two things you need to do.

1) create as a “once off” a pair of private & public keyserver-options.
2) Give the details of the public key to the AUR server.

Creating SSH Keys:

Lets start with item 1):

ssh-keygen is a utility of openSSH so you need to install that, then from a terminal simply issue the command (as a normal user not sudo): ssh-keygen

To keep things simple, you can accept the defaults by hitting return button.

At the end you should see something like in the adjacent image.

ssh keygen
Yours should look pretty similar to this!

Note: At this point, you can generate a password/passphrase. Doing so can increase the level of security, but the choice is yours to make.

Now lets look at 2):

From your terminal, check you are in your home folder, or cd to it eg ($ cd ~ )
Then change directory into the .ssh directory with cd .ssh
Then get contents via cat
cat : [andrew@darkstar:~/.ssh]$ cat id_rsa.pub

You should get something like : ssh-rsa AAAAB3NzaC1yc2EAAAAD… There will be something like 569 chars in all. 

From the terminal you can just copy starting from the ssh-rsa ….. to the end; then you can just paste that into a text box asking for your public key.

A quick warning the two keys generated are a matched pair. Once you submit your public key, don’t just repeat the default way of generating keys otherwise the keys will be overwritten and then you will be rejected from getting access to where you last put your public keys.

Also to see the .ssh directory in your home folder, you may need to click view hidden files and dirs.

Closure:

And there you have it, a guest-authored article about SSH keys! I’m very grateful for the help. If you’re interested in writing an article, you can do that. The easiest way for you is to use the Contribute Your Article link at the top of any page. The easiest way for me is if you just register and ask to be made an author. Either is awesome and even if you’re an author I will still need to edit and schedule posts.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment

How To: Find Your Uptime In Linux

This article will do a bit more than help you find your uptime. There are a number of other thing that’ll be covered, but they all have to do with your uptime.

So, what is uptime? Uptime is how long your system has been up and available. It’s a useful metric, especially if your system is public facing or providing some sort of service that people depend on. In fact, Wikipedia has a definition!

For example, it’s a metric that matters a great deal in web hosting

That link is a link to my small hosting offering, but scroll down to the bottom at said link and you’ll see a link to check the uptime. In fact, I’ll save you a click and you can just click here.

That link is one way of examining system uptime and availability over the internet over a period of time that’s expressed in a pretty manner. You too can find the uptime of at least the system that you’re using, but we won’t be covering pretty graphs or network availability.

In this article, you’ll find your uptime by using the terminal. We’ll cover a few different ways as well as examine the uptime command.

By the way, you can just type man uptime and see how to use the command. It’s not exactly complicated. Anyhow, uptime defines itself as:

uptime – Tell how long the system has been running.

And that’s a pretty accurate statement. So, let’s examine that first!

Find Your Uptime:

For this exercise, you’ll need an open terminal. To open the terminal, just press CTRL + ALT + T and your default terminal should open.

Once the terminal is open, let’s start with the basics:

That’ll give you a basic output, along with your load averages. If you want a more easily readable output, you can just use the -p flag.

If you want to know when it’s counting from, when your system became available, you can do that. To do so, it’s just the -s flag.

That’s pretty much everything that the uptime command can do. That’s not the only way to find your uptime, however. For example, you can open top or htop and see your uptime. If you use htop, it looks like this:

htop showing the uptime
See? It’s right there! It’s in ‘top’ as well. Now you know!

You can also use just a ‘w’ easily enough. It too will find uptime it looks like this:

You can also use ‘screenfetch‘ or ‘neofetch‘ to get your uptime. If you have one or both installed, the commands would look like one of the below:

Both of those will find your uptime and display them.

As you can see, there are many ways to find your uptime. In fact, I’m sure I missed some ways that you might use. If you use a different method, or know of another method, please feel free to leave a comment below!

Closure:

Well, this is it. It’s another article. I must be approaching the halfway point. The goal is to keep this project going for a year and to reassess at that time. If it’s something that’s popular, beneficial, and I’m not burnt out, I’ll keep going with it. Maybe by then someone else will want to take over or help write some stuff? Who knows? We’ll find out at the end of the year!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Display System Information With screenFetch

I have previously written an article about screenFetch vs. Neofetch, and it’s one of my most popular articles, but this one will tell you how to display system information with screenFetch. Why screenFetch? Why not? It’s perfectly usable and this gives me the chance to be more thorough than the previous article.

I suspect I’ll do a similar article about Neofetch, but today is not that day. No, today is about screenFetch (which is horribly stylized with just a capital in the middle) and it’s a fine tool to display system information. In fact, it describes itself as:

screenFetch – The Bash Screenshot Information Tool

screenFetch is one of the tools that displays system information in the terminal. It does so with the goal of being displayed in a screenshot so that you can brag to your friends. It really doesn’t have a whole lot of value beyond that, but that’s fine. It’s informative and handy, and suitable for purpose.

So, without further ado, let’s get into this!

Install screenFetch:

Fortunately, screenFetch can be easily installed and it’s widely available. You can install it from your default repositories easily enough. There’s some odds that it’s already installed by default and, if not, we should be able to get you squared away. 

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open. With that terminal open, let’s get screenFetch installed with one of the following commands:

Fedora:

OpenSUSE:

Debian:

Manjaro:

If none of those work, you can just try installing it as you’d install any other app from the terminal. Chances are really good that it’s in your default repos, so  you can graphically find it through your software manager. In fact, it is often installed along with the OS. Now that it’s installed, let’s move on.

Display System Information With screenFetch:

It’s pretty easy to get the basic output. You really only need to enter:

As I mentioned above, screenFetch is meant for screenshots. Sou can get screenFetch to automatically take a screenshot and drop it into your ~/ directory. Just use this command:

If you plan on sharing this information on forums and to show off to your friends, screenFetch has another neat feature. You can not only take a screenshot,  you can theoretically upload it automatically. To do so, you’d use this command:

However, that currently appears to not work. It’ll seemingly upload the screenshot, but it doesn’t give you a direct link to the screenshot. That’s not helpful – but I’m pretty sure this used to work. As screenFetch hasn’t been upgraded in a while, it may be that the image hosts have changed their API. Dunno, ‘snot my job to know. I suspect it’ll someday work again, should the devs continue with the project.

Anyhow, that’s how you use it. You can run man screenfetch to get more information, but the general usage explained here is about all you’ll really use. The point of this article was more to share how install screenFetch than how to display system information with screenFetch.

Closure:

And there you have it, another article. The goal of this one is more to tell you how to install screenFetch in various distros. Once you have it installed, it’s pretty easy to use screenFetch to display system information. If nothing else, it’s yet another article in a growing list of articles.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Create A New User With SUDO Privileges In Ubuntu

It’s not unusual to want to create a new user with sudo privileges and it’s actually really easy. This will be just a quick article that explains how. It’s not exactly a complex operation.

This article doesn’t cover other distros! It has only been tested in a couple of Ubuntu derivatives and not all distros come with ‘adduser’. It should probably work if you install ‘adduser’ where available, but that’s entirely untested by me. Give it a shot and let me know in a comment if it works out for you.

You may want a multi-user environment, you may want different logs for different users, you may want some customization with one user, you might want to test things with a separate user, etc… There are tons of reasons for wanting a different account and wanting a new user with sudo privileges.

I shouldn’t need to mention this, but sudo stands for ‘superuser do’. Users that belong to the sudo group are pretty much omnipotent. They can access anything, change anything, and do anything they please. You’ll use sudo to do things like install software or edit system files.

Anyhow, I’ll explain how to create a new user with sudo privileges in this article. It’s a pretty easy task and you shouldn’t have much trouble with this one.

Create New User With SUDO Privileges:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

The tool we’ll be starting with is called ‘adduser‘, and the name tells you what it does. With your terminal now open, you start by entering the following to add a new user:

Once you’ve done that, you’ll be asked to type the new user’s password twice, and then you can fill in some additional information for that user. Those steps aren’t necessary, but you will want to add a password for the user – and definitely so because it’s an account that has access to sudo.

Now that you have created a new user, you’ll need to modify that user. The newly created user doesn’t come with sudo access by default, you need to grant it. The tool we’ll be using for this is ‘usermod‘ and the command to make the new account a new user with sudo privileges is:

At this point, you should be able to login and use the newly minted user account. Indeed, you should have a new user account and that new account should have sudo privileges.

CLOSURE:

See? I told you that this wouldn’t be a long or difficult article. If you want a new account and you want that account to have sudo privileges, it’s just a couple of easy commands away. This is yet another article in what’s turning out to be quite a long list of articles.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.