Common locations and tools
Intimidating to be the first to post here, but I'm sure I'll get something wrong, and there's nothing like correcting someone for activity eh? ๐
So for a first off-the-cuff post, I thought I would just explain some file locations you'll see a lot learning linux, and mention a few tools. Feel free to add more of both in the comments!
Locations:
/ The most important location on any Linux machine, not to be confused with root's home directory, this is the starting point of the Kernel's access to any file, and in Linux everything is a file. This isn't a hard drive itself, but often points to the base of a hard drive. During bootup, one of the key steps is mounting the / filesystem. Essentially the operating system needs to establish a common logical tree to find things, and this is the base of that tree. I'm sure there is some exceptions I can't think of, but everything actively being used by your system will be under here somewhere.
.
.. Related so I'll tackle these together. The . and .. directories will be found as children of every folder on your system, and point to places relative to your current one. The . directory is the equivalent of your current directory. .. points to the directory that contains the one you are in. Also . has a special meaning as the first character of a file name. It indicates in that case the file should be hidden to programs that respect that.
/home This is a very common, but not universal folder under root. It is semi-equivalent to the Users directory in windows. Most users will have a folder under here to store their files. /home/root/ is the typically inaccessible to non-privileged user home for the root user for instance. As a bonus ~/ will point to your own home folder on most systems.
/bin Home of the binaries. /bin, /sbin, /usr/bin and /usr/sbin are where most local applications will be installed. Don't remember the exact distinction between /bin and /sbin but sbin seems to contain more system utilities.
/usr is a directory for holding user files. Not the same as home, but I think in the sense that they are distinct from system files and libraries
/lib where most libraries go. /usr/lib is also around for this. You likely won't spend much time here.
/etc the place for all your system configurations. This contains mostly text files that are read by various programs for default settings. Only edit here if you want a change for all users. Usually for one user programs will read a file in /home/user/.config or a similarly unique to them locale.
/boot Not always around, but as you can imagine it holds important files for starting the system. In most Linux distros the file that contains the Kernel is in here, along with some other tools to help get you to a full machine. Don't mess around in here until you're ready to dig in.
/sys /proc These directories are used to store and display information usually used by the kernel. Both very powerful and very dangerous. Writing into the wrong file here can change electrical settings for devices, and it is easy to get lost in the looping/nested structure
/dev This is where your devices are kept. When you need to tell a program where a peripheral, a disk, or an internal resource can be accessed this is the folder for it
Tools:
Running out of steam so I'll keep it short
-x If I use this I mean a flag passed to the command. So cp is the copy command. If I want it to work recursively and copy subdirectories I need to give it the r flag. So the command becomes cp -r
ls LiSt files. Basically just prints out the contents of a directory. -a tells it to list everything even hidden files
cp for CoPy
cd is Change Directory
du lists Disk Usage You can use -d to ask it to summarize things up to a Depth and -h to ask it to print sizes in a way that is human readable
df lists Disk Free
sudo is used to run a command as root. This one comes from su the program it mostly replaces, which itself is I believe for Super User. So sudo is really Super User Do.
Lastly some flags are respected by many different programs. Not all, but many. So -h for help, -v for extra logs, and -V for version for instance are very common
That should be enough to get things started. Please chime in with essentials I missed, mistakes I committed, or tricks with any of the commands.
10 replies
/home/roottypically doesn't exist. the root user's home directory is generally/root. most people should never do anything with root anyway. everyone should learn and usesudoor something similar instead.fun fact,
cd ~grecowould take you to my home directory, if we were on the same host.lastly, don't use arbitrary flags in commands.
--helpshould be safe, but otherwise, look up an app's usage with something likeman dffor the manual.another fun fact:
man manis a good place to start.honestly, great first post for the community. i look forward to watching it grow. thank you for taking initiative on this.
Thank you so much for the compliment, and thank you for adding more! I've definitely encountered programs using flags in ways I didn't anticipate before ๐
As a general note, some distros, the most popular I can think of is openSUSE, default to su to escalate privileges.
Also try
aproposto help figure out what command might do the thing you want. It's not perfect, but sometimes it can give a good answer.Rereading made me already remember one I mentioned but didn't explain.
mountis the command used most often to make hard drives accessible in the file system. Typically you need a folder to use, and then you tell the systemmount /dev/sdb1 /home/user/userMountor similar. Thefstabfile in/etcwill usually have a list of entries of devices that are automatically mounted on startupThanks for making the first post have a great day
Hey, awesome guide but 'libraries'? I don't think that's as straightforward as one could think?
๐ I've done the classic XKCD of assuming too much domain specific knowledge.
Computer programs often have to use behavior that isn't defined by the author. Think about how hard programming would be if you had to rewrite code to display text every time you wrote a new program. So often code relies on external implementations of functionality to reuse common sections. These common sections are kept in library files. On windows they are typically distributed as
.dllfiles, or Dynamically Linked Libraries, on Linux they typically use the.soextension for Shared ObjectDynamic in this case contrasts against things compiled statically. When a program is compiled it has to be linked against the libraries that it uses, so it knows where to go when its time for those calls. Statically linked programs, copy the sections of the libraries into their binaries, while dynamically linked libraries are stored in separate files to save on file space. Then at runtime, the dynamically linked program will search for the missing code in a specific order based on your systems variables.
/libis the primary storage place for those libraries on Linux.Awesome. I confess I knew a bit about libraries and my question was a bit oriented towards what felt kind of recursive in the OP. Turns out I still learned a lot. Thank you.
suis actually "substitute user", sosudois actually "substitute user do [something]".Two simple but very common commands I like:
pwd- print working directory - basically "WHERE THE FUCK AM I RIGHT NOW???" :)clear- clears the terminal giving you just one nice clean prompt. Very handy if you've copied everything you might need and want to run a command with a lot of output that you know you'll want to copy - it makes it easier to copy what you want because it clears off all the clutter.It's also fun to mention that when you are changing directories, since
..means the directory-above-current-directory, you cancd ..to go up one level, but you can also docd ../../..to go up three levels, orcd ../../mediato go up two levels then one level down into a 'media' folder.It might also be worth mentioning tab completion that most shells have.
nanois a common text editor, and so say you want to edit /home/daychilde/media/somelongfile.txt, you can start typingnano /home/da- hit TAB and if daychilde is the only location that starts with 'da', it'll complete that part and leave you withnano /home/daychilde/so you can type part of all of 'media', slash, start typing that long file name and hit TAB to complete it. If there's multiple matches, it'll add what it can until there's multiple possible items. But you can always type another letter or two (or number) and hit TAB again. :)Lastly, if you're a terrible typer, you may want to install the "sl" package as it makes it fun when you're trying to list files but you make a typo. :)