29

I was a Windows user and am new in Linux environment. I just installed Ubuntu two days ago and I am confused about the directories such as lib, etc, var, tmp, mnt, etc. I've few questions.

  1. What is the purpose of these directories?

Currently I keep my project files in /home/shifar/Public/Projects, but that sounds too long...

  1. Is there any way to shorten the file path?

  2. Is it good to keep my project files in the above mentioned directory? Or is there any convention? Like Personal files must be stored there. and Software is better stored in there..

  • 4
    You can use whatever path you like under your home dir (/home/shifar that you can contract as ~ in most shell). For more info on unix standard filesystem structure, look here for example: tutorialspoint.com/unix/unix-directories.htm – Rmano Dec 9 '15 at 10:49
  • 1
    Don't ever mess with directories under /, if you need to know what they are google FHS. Search for symlinks. And... depends. – Braiam Dec 10 '15 at 1:43
  • 1
    How does /home/shifar/Public/Projects compare for length to C:\Documents and settings\shifar\My Documents\Projects (or in a more modern sense C:\Users\shifar\My Documents\Projects)? – Chris H Dec 10 '15 at 9:15
  • @Chris My Projects folder was in D: drive. so /home/shifar/Public/Projects is smaller than D:/Projects. – theapache64 Dec 10 '15 at 9:18
  • 1
    I am wondering, why this question has 16+ upvotes and 1600+ views with 3+ days? :/ – theapache64 Dec 15 '15 at 6:52
47

What is the purpose of these directories?

  • lib: kernel modules and those shared library images (the C programming code library) needed to boot the system and run the commands in the root filesystem
  • etc: configuration files
  • var: files to which the system writes data during the course of its operation
  • tmp: temporary files
  • mnt: the temporary mount points for mounting storage devices

Is there any way to shorten the file path ?

Instead of call /home/shifar you can use ~/

Is it good to keep my project files in the above mentioned directory? Or is there any convention ? like Personal files must be stored there... Softwares is better stored in there... like that.

/home/shifar is your home dir and dedicated for your personal uses. You can store your personal dirs, files in any dirs in it. ~/Documents may be a good place for Projects. ~/Public is normally shared to anyone in the network. So if you do not want to share, put your files in another dirs instead.

  • what about the above ones? – Tung Tran Dec 9 '15 at 10:51
  • yeah, that too useful ! but the last para, that's what i wanted . :) – theapache64 Dec 9 '15 at 10:55
  • 2
    If I may add, the home directory also can be re-expressed with $HOME variable, e.g. cd $HOME/Documents – Sergiy Kolodyazhnyy Dec 10 '15 at 15:51
  • I didn't knw dat, thanks @Serg :) – theapache64 Dec 12 '15 at 10:49
7

The previous answers are all good. I would just add a few points.

Later, (not now!) when you're more comfortable with Linux, you may want to create a separate partition for data - especially if you have big files like lots of music or video. If you add too many of these to your home partition, you can fill it up and then other things stop working because they can't get the disk space they need.

If you fill up a data partition, it doesn't affect anything else.

Also, when you want to backup your data, you can just do it any time. /home has things which change all the time, so you can't normally "freeze" it to get a copy where everything is in sync. With a separate data partition, you can make a perfect backup any time.

As far as paths go, if you are working from the command line, you can define a bash alias (in ~/.bashrc or in ~/.bash_aliases) to shorten any path or even to change into the directory.

alias proj='cd /home/shifar/Public/Projects'

and then just type proj to switch to that directory.

When you get more comfortable with bash, you can do even more with functions. But, we'll leave that till later.

Another approach would be to add a line to ~/.bashrc like

export PROJ='/home/shifar/Public/Projects'

That would make an environment variable PROJ available for use and you could do things like:

ls "${PROJ}"
cd "${PROJ}"
cp mynewfile "${PROJ}"

It will also work without the export in front of it, but then it would only be defined at the top level of your shell, not in any subshell you might run from there.

You don't strictly need the quotes or braces in the example above either, but they protect you from things like embedded blanks and also allow you to use PROJ as part of a word - like ${PROJ}ect.

  • Wow, that sounds like a good approach. Thanks Joe. By the way, I think the alias' lifetime is just upto the restart, isn't? Should i set the alias on each startup or is there anyway to set the alias permanently ? – theapache64 Dec 17 '15 at 2:55
  • 1
    Right. Generally, you would add the alias definition in .bashrc in your home directory, or , if you have it setup to be read, you can add it to .bash_aliases in your home directory. An alias only works at the start of a command line, but a function will work anywhere. They're just a bit more tricky to use for something like this. – Joe Dec 18 '15 at 11:18
1

Ubuntu is just like your own conventional Windows. Only it is a different operating system. I am not sure what version of Ubuntu you are using. Regardless of that, Linux Environments including Ubuntu all offer a very user friendly GUI just like that of windows which shouldn't be difficult to understand for someone who is used to windows. If you're not comfortable with the terminal, you can always just use the GUI and access your files and folders from there.

As far as where you should keep them, again, it's your own desktop. It's just a different system. It is exactly the same as windows. Just store them where you would store them in windows.

The file path can be shortened. You are currently in Projects. You can move up the tree and store your files in, let's say "home" folder. It's all up to you. But it is generally a good idea to keep personal files inside your username, that is "shifar" in this case.

The "/" indicates the root directory. It contains "home", which contains "Shifar" and so on. They are solely for keeping data classified and organized. A directory is what you would call a folder on your windows.

Hope this helps.

  • I've defined my ubuntu version in the tags which is 14.04. :) – theapache64 Dec 9 '15 at 11:01
  • 8
    If I was an Ubuntu newcomer reading this answer, I would be still confused, but on a higher level... :-/ – Byte Commander Dec 9 '15 at 13:08
  • 1
    Yeah I don't understand why this is upvoted, this is very confusing. And explaining that directories are the same as folders on windows? I think this person knows that.... – Rob Quist Dec 9 '15 at 14:10
1

The files are personal as in you don't want other people looking at them, your home directory is a good choice, but you should also understand file permissions -- not directly on point to your question, but relevant. You should set your permssions as restrictive as possible, as permissive as necessary. Also, if you're concerned about privacy and security, Ubuntu provides a way to encrypt only your home directory, so you can keep your sensitive data quite secure. It's somewhat technical (https://help.ubuntu.com/community/EncryptedHome).

My usual practice is to encrypt/decrypt sensitive data files one-by-one using gpg -- https://help.ubuntu.com/community/GnuPrivacyGuardHowto. This is also kind of technical but really important and worth your effort.

I've never felt much compulsion to use the subdirectories in my homedir that Ubuntu installs. You're free to organize your data as you see fit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.