Change Your Home Directory

In today’s article you’re going to learn that it’s possible to change your home directory. Why? Because Ol’ David is in a bit of a rush to get this out on time. I can’t miss my publication deadline! So far, there has been an article every other day. Gotta keep up the schedule.

Yesterday was an extremely frustrating day. People managed to waste my entire afternoon. The only consolation I got was that I drove home really quickly, in a very spirited manner. That was not enough consolation. So, I just drank a couple of delicious beers (Sierra Nevada Pale Ale) and went to sleep.

I expected to get up early and write the article. I did wake up early, but I fell back to sleep. My body wanted to catch up on some missed sleep and it did. Which means I’ve got like an hour to write this article.

(I don’t think there has ever been a more ‘bloggy’ post than this one! It’s horrible and I’ll hopefully never do it again.)

When I first planned this article, I planned on showing you how to change your home directory with a new user. It was going to be fairly long and needlessly complicated. So, instead, I’m just going to tell you how to do it. You can learn how to create a new user.

So then, let’s get onto the meat of this…

Change Your Home Directory:

There are all sorts of reasons why you might want to change your home directory. Maybe you don’t want people being able to easily spot it by traversing your directory tree? You might want to move it to a different partition that has more space? Who knows?

But, this isn’t something you want to do willy-nilly. See, a whole lot of things depend on your home directory and your home directory probably contains a lot of stuff. So, after you’ve changed your home directory you’re probably going to need to move a lot of stuff around. That’s why it’s best to do this with a new user. If you want to practice this, I’d say do it to a new user. There’s a link in the preamble to learn how to create a new user.

The command is remarkably simple. Just open up your terminal and run:

So, if I wanted to move my home to /foo/bar, the command would look like:

You don’t have to specify /home/kgiii – even though that’s the full directory path. The -d command knows that we’re generally talking about the home directory. If you’ve already moved your home directory, and it is outside of the /home directory, you’re probably gonna have to specify that. I don’t actually know, I’ve never tried that.

This isn’t something I’d undertake lightly. I’d really only recommend this on a new user OR if there are some very specific circumstances. You might do this if you’ve filled up your disk space, added a new disk, and want to move your home directory to the new disk so that you don’t have to muck about with changing partitions or anything. Even then, it’s a bad solution – but probably one of the best solutions you have available.

Closure:

Consider this an article that’s for a very special set of circumstances. It’s for when someone on a forum has run out of disk space and wants a way out without any changes to partitioning and doesn’t want to reinstall. This isn’t something you probably need to go playing around with, but you can. I ain’t stopping you. The potential to make a mess of this is pretty strong.

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.

Meta: The State Of Linux-Tips #10

This is going to be another meta article, where we cover the state of Linux-Tips. This is the 10th such installment, I do believe. I did go back and count at one point, but not all that well or that deeply. Not all meta articles have been the state of Linux-Tips. So, this is #10, even if it’s not #10.

I think the big news is that we’re out of the doghouse with Google. Last month we averaged a few hundred unique visitors every day. This month  looks like it’s going to be even better. I dare say I learned my lesson. 

The site still chews through a bunch of bandwidth, for a site like this. We chew through the CDN data pretty quick. Fortunately, I can cover it when it inevitably goes over the current level. 

I actually got a donation! It was for $5.00. PayPal decided I’m a business account, so they happily took their fees from it. I no longer have access to ‘Friends and Family’ payments. Damn it, PayPal! Though, in their defense, I am a business –  and conducted quite a bit of fee-free business through them in the past. For the services they provide, it’s really not that expensive. Sign up to be a credit card processor and check out those fees!

I was pretty pleased with the donation. I don’t need the money, but it gave me a sense of purpose – of value. It felt good to know I was appreciated. That makes TWO donations! I’m gonna be rich! 

Some Meta Stuff For Linux-Tips:

In the past 28 days the site has shown up in Google searches 180,000 times. Only a little over 3000 people clicked. That was improving from my days in the Google penalty box.

(Keep in mind that Google actually sucks at some of these numbers. I have the raw server logs. They really, really suck with some of them. We’ve actually shown 55,000 pages so far this month alone.)

Most of my traffic comes from Google. They tell me that the vast majority of people are on desktops. The vast majority of visitors arrive from organic search.

The most popular pages have changed. Here are the three most popular pages:

How To: Disable Sleep And Hibernation on Ubuntu Server

Repair Your Linux Filesystem With a Live USB or DVD

How To: Restart TeamViewer From The Terminal

Though, screenfetch vs. neofetch seems to be the article that shows up in search the most. 

Since I’ve was let out of the Google penalty box, I haven’t had a day with less than 200 unique visitors. (That’s a good amount for a fairly new site that doesn’t do a lot of SEO and does no paid promotion.)

We’re sitting at 260 articles, with one being hidden. We’ve had a new article every day since the site first started. Obviously, we’re well past the year I originally set aside for the project.

There are ads here on Linux-Tips and they get the occasional click. Most of my readers are technical users and tend to block ads. It’d be pretty sweet if you’d whitelist this site in your ad blocker. They’re just Google ads. They won’t hurt you. If you were really trying to hide from Google, you’d block their analytics. Meh… Or not… It’s up to you. I’ve long since decided that finances aren’t that important. ‘Snot like I’m going to stop paying in the near future.

Lemme think…

Closure:

Anything else? No? It had been a while since I last did a meta article. I should do them once a month or so. They’re easy enough to write, but they don’t really contain any useful information.

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.

Let’s Make A Symbolic Link

In this article, we’re going to learn how to make a symbolic link. This will be a very easy article, and one you may get some use from. It’s not terribly hard to make a symbolic link, though I suppose the syntax may seem quirky as compared to many other commands. It’s not hard, trust me on this… Or not… You can pretend it’s hard and impress your friends and family!

Ah well…

So, what’s a symbolic link? Well, it’s a link to another file. A symbolic link is a file that contains nothing more than a link to another file. There’s a hard link as well, and that points to an inode. A symbolic link is a bit more versatile. You can make a symbolic link (again, a file) and move it around the system and it’ll still point at the original file. It’s useful if you want to do things like put shortcuts on your desktop.

This being Linux, everything is a file. A symbolic link is a file. It is a file that contains information about where another file is located. Some folks think this sort of stuff is complicated, perhaps too complicated for a new Linux user, but I think it’s easy – so long as it’s properly explained. Darned if I know how to explain it! I hope that worked for you. That’s really all it is. That’s it. It’s just a file that contains information about where another file is located. Everything is a file.

Like I said, this is going to be a short article. It really shouldn’t be all that difficult to show you how to …

Make A Symbolic Link:

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.

Now, pick a file… One that most users will have will be your Bash history, located at ~/.bash_history unless you’ve really done some heavy modifications. Let’s use that file to make a symbolic link.

The format to do this is:

Obviously, the -s means ‘symbolic’ (feel free to check ‘man ln‘ for more information) and you name the existing file first and then the file you want to create. So, to do this with .bash_history, it’d look like:

Now, you can see it in action:

Tada! It will show the contents of your .bash_history if you did everything correct. Want to see something even more handy?

Now, look at  your desktop and open the file named ‘test’ – or just navigate there in your terminal and check it again with the cat command:

Congratulations! You’ve learned how to make a symbolic link! I told you that it wasn’t all that hard. As a concept, it’s even easier to understand. The syntax to do so isn’t even all that difficult. You’ve got this! I have faith!

Closure:

Yes, yes I did say this would be quick and easy. I think it was. It’s not terribly hard to make a symbolic link and it was a fun article to write. It’s fun to cover some of the basics. As the tagline says, “Getting you up to speed!” Search around or just browse, you might be amazed at the subjects covered!

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.

Search For Command History By Date

Today’s article is going to show you how to search for the command history by date. This isn’t hard, but might seem a little advanced for some of the newer users. We’ll be doing this through the terminal, of course. That seems like a good idea to me!

Unless you’ve made some fairly drastic changes, Linux terminals keep a log of previously entered commands. This is on a per-user basis and considered relatively secure, or at least as secure as your user account is. It’s helpful to be able to look at your command history, especially if you’ve forgotten what you did and you really need to undo it!

Previous history articles include:

Delete An Entry In Your bash_history

Dealing With Duplicates In Your Bash History

So, I haven’t really covered the .bash_history (proper name, I suppose) all that much. There really isn’t all that much to cover, but today we’ll learn how to search your command history by date. It’s most useful when you remember when you made changes but you can’t remember the precise commands used when you made those changes.

Find Command History By Date:

Like oh so many articles, this one too requires an open terminal. You can open one easily enough. Just press CTRL + ALT + T and your default terminal should open.

With  your terminal open, we first have to tell Bash to store and show dates along with the history. That’s an easy command that you need only run once:

When you next type ‘history‘, it’ll look like a hot mess until you figure out what the command has done.

Now, to find command history by date. To do that, you just enter:

The format for me is YYYY-MM-DD, though I suppose it could be different for others who have an alternative date format set up. I don’t really know, but it’s easy to figure out by just running the history command and deducing the format from those results. If you’ve done it properly, it might look a little something like this:

searching command history by date
See? It works! It does show the command used to show these results, of course.

So, if you want to see what commands were run on a certain date, you can do that. You can also find what you entered when you remember the day but not the commands you entered. It can be pretty handy so search the command history by date. Keep it as a handy tool, as you never know when you’re going to need it.

Closure:

And there you have it. You have another article in a very long list of articles. This one is  handy if you need to know your command history by  date. I know I’ve been known to use this myself, largely because I sometimes need to narrow down my history quite a bit, as I do a great deal in the terminal and my history is a hot mess.

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.

Let’s Find The Size Of A Directory

Today’s article is one where we’re going to find the size of a directory. Why? Because that sounds like something fun to do. The site has more than 250 articles, most of which are reasonably productive and authored by me. (I do love me some guest articles – so long as they’re from the community. No more paid stuff! That lesson was learned.) They can’t all be winners!

So, why would you want to know the size of a directory? How should I know? Maybe you need to make space? You could want to upload the directories and want to know if you have space at the destination? Perhaps you are going to transfer the files and you want to estimate how long that will take? You do you. I don’t care why you want to find the size of a directory. That sort of thing is between you and your directories!

Anyhow, we’ll be using ‘du’ in this article. If you want a GUI way to find the size of your directories, you can visualize disk usage easily enough. You can also easily find large files. You shouldn’t need to install ‘du’, it should be installed as a part of the standard toolkit (GNU coreutils). To find out if you have ‘du’ installed, you can just try du --v in the terminal, which will spit out some version information.

So this should be a fairly short article – nice and easy. Let’s get on with it!

Find The Size Of A Directory:

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.

We’re going to us ‘du -h‘ for everything, because that -h stands for ‘human readable’ and it’s just easier than seeing byte sizes. You don’t actually have to use the -h, it just makes good sense to do so.

The format for this is largely ‘du -h /directory‘, like so (using the Documents directory as an example):

You can just add more directories as needed (we’ll add downloads):

That will output the size of both directories. If you are unaware, the ~ (tilde) is a shortcut meaning your home folder. For example, if you’ve navigated away from your desktop, you can cd ~ and get back home. It’s faster than clicking your heels together three times!

By the way, if you’re stringing directories together, you can get the total size of the directories with the following:

That’s about it. That’s all you really need to know for this exercise. I told you that it’d be quick and easy! Most of my articles involve opening the terminal, and yet so many of them are really quite simple to learn and remember. I strongly urge new Linux users learn a bit about the terminal, not because it’s hard but because it’s often easier and faster than using a graphical tool.

Closure:

I wasn’t kidding about there being more than 250 articles. There are 256 of them at this time, and this will make 257. So far, I haven’t run out of ideas and I’ve been able to get one out to you every other day. I hope you find these articles as useful as I’d like them to be. It does take me longer to come up with ideas, so it might have to slow down at some point. I mean, I can’t keep writing these kind of articles forever,  can I? No… No, I don’t think I can.

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.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.