A primer on how I use Linux.
[21:36:43] A: I have severely lacking knowledge of what the convention for the contents of the different linux folders are.
[21:37:41] Will: everyday ones…
[21:38:10] Will: system binaries go in /bin, obviously, including GNU tools like ls and netstat
[21:38:33] Will: /usr has a lot of stuff relevant to users
[21:40:10] Will: applications installed by users, for instance
[21:40:25] Will: I keep all the interesting stuff in ~/opt
[21:40:32] Will: and just add that to my $PATH
[21:40:46] Will: that means I can invoke them in any shell
[21:40:49] A: Huh, I’ve always wondered where the canonical directory to put installed applications in is. Like stuff that I can’t just apt-get
[21:41:12] A: What does opt stand for?
[21:41:29] Will: not sure actually
[21:41:49] Will: it is a standard name for a directory that contains applications you want to use though
[21:42:04] A: Huh, ok. Is that the case for /opt as well?
[21:42:39] A: Judging by its contents on my machine, yes.
[21:42:49] Will: apt installs things to /usr by default
[21:43:01] Will: that’s a standard place, a lot of applications respect that
[21:43:23] Will: I usually like to keep things ‘where I can see them’ in ~/opt
[21:43:54] Will: protects you from losing your programs if you migrate /home to a new volume for instance
[21:44:16] A: Right, ok.
[21:45:15] Will: /etc has, like… stuff
[21:45:20] Will: pretty random
[21:45:31] Will: /dev has your devices
[21:45:52] Will: direct handles into your hardware
[21:46:18] Will: contains /dev/sda, your first HDD-like device
[21:46:38] A: ok
[21:46:46] Will: /dev/sda1 is the first partition
[21:47:00] Will: i.e. sudo mount /dev/sda1 /media/hd1
[21:47:25] Will: (specify type with -t )
[21:47:42] Will: that mounts the first partition to a filesystem at /dev/hd1
[21:48:01] A: ok
[21:48:23] Will: sudo umount /media/hd1 to unmount
[21:48:33] Will: (command names are weird)
[21:48:52] Will: /var contains logs
[21:49:11] Will: it’s where the stuff installed in /usr writes files (logs, output, etc.)
[21:49:26] Will: kernel trace is here (I think)
[21:49:33] Will: run
[21:49:57] Will: that’s your kernel trace. commands sometimes tell you to dmesg | tail in order to see where something went wrong
[21:50:06] Will: if a mount fails that’s what it tells you to do
[21:50:35] Will: says things like “kernel module A screwed up trying to do B” so that’s good to know
[21:50:47] A: Oh, cool.
[21:51:20] A: I really appreciate this btw, this helps fill a big hole in my unix knowledge, thanks
[21:51:44] Will: I’m personally overjoyed at being able to remember it all
[21:51:57] Will: took a while
[21:52:10] Will: you really need a bias for action when using linux
[21:52:39] A: What do you mean?
[21:53:00] Will: if you encounter a problem keep throwing solutions at it
[21:53:19] Will: there’s insane amounts of data, you need to plough through it
[21:53:44] Will: most of the time your investigation hinges on knowing a single device name or something
[21:53:55] A: Heh, yeah
[21:55:05] A: The user is expected to know a lot more about the underlying OS specifics on linux than with iOS or Windows.
[21:55:33] Will: swings and roundabouts, at the end of the day
[21:55:38] Will: it’s all relative
[21:55:42] A: When I’m not encountering random issues I don’t know how to deal with, everything is fine. But when I get something that requires me to really know linux, I fail.
[21:56:44] Will: just a matter of perspective. if computers needed you to run on a treadmill while you used them, would it matter that much if it was 1m/s or 1.1m/s?
[21:57:32] A: Not getting the analogy here.
[21:57:33] Will: but the 1.1m/s can code properly
[21:57:48] Will: all computers require maintenance
[21:58:09] Will: and are you kidding? people come to me with problems on windows all the time
[21:58:15] Will: like “given up, fix it William”
[21:59:10] A: Yeah, true I suppose. But there are more built in tools for avoiding common issues or troubleshooting them in the more commercially mainstream OSs, I feel.
[21:59:39] Will: yeah, by nature of the fact it’s less popular
[22:00:32] Will: I’d say it’s just a little more difficult. the main problem is knowing people who can fix it. there’s an order of magnitude less of those for linux than any other OS
[22:00:48] A: Mm.
[22:00:49] Will: at least you’re not running BSD
[22:01:42] Will: your life dominated by one 5000-line perl script that uses dark zombie sorcery to boot your OS
[22:02:07] A: Sounds thrilling.
[22:02:15] Will: that’s what I imagine it’s like
[22:04:47] Will: /proc, /run and the other guys are basically not interesting
[22:05:31] Will: if you one day get to the end of your tether about what your processes are doing you’ll probably end up in there with gdb trying to tell arse from elbow
[22:06:20] Will: ifconfig lists network interfaces, netstat lists network processes
[22:06:41] Will: sudo netstat -lp
[22:07:05] Will: -l listening (processes)
[22:07:09] Will: -p process names
[22:07:23] Will: sudo because root has the authority to know the names from -p
[22:07:53] Will: netstat -ln to get port numbers and that’s basically it
[22:08:07] A: Aha. I was wondering why sudo, because it seemed to work also without, but I see now.
[22:08:20] Will: networking tools are important to understand unfortunately
[22:08:27] Will: you’ll be using them a lot whether you like it or not
[22:08:45] Will: wireless is a hack too with them not being supported as first-class interfaces
[22:09:00] Will: it’s an ‘extension’ (idk) of a standard ethernet device
[22:09:12] A: hrm, ok
[22:09:15] Will: wired connections like eth0 are simple though
[22:09:19] Will: sudo ifup eth0
[22:09:22] Will: brings it up
[22:09:28] Will: ifdown to take it down
[22:09:43] Will: get used to acronyms too
[22:09:56] Will: if, nic, so on
[22:10:21] Will: ah, right, that’s why /etc is important. it has this stuff in it
[22:10:36] Will: I think ubuntu has /etc/init.d
[22:11:03] A: That sounds vaguely familiar
[22:11:06] A: What is nic btw?
[22:11:14] Will: I think that’s a debian thing. anyway, those are init scripts (do things when the OS changes mode like booting up)
[22:11:19] Will: network interface card
[22:11:27] Will: /etc/networking
[22:11:34] Will: network/, rather
[22:11:37] Will: /etc/X11
[22:13:11] Will: so yeah, it may seem crucial while using the computer, but stuff like graphics and networking end up in /etc
[22:13:43] A: ok
[22:14:24] Will: /etc/hosts, too, but that’s only important if you’re running a server
[22:14:56] Will: that’s the important stuff
August 31, 2014Uncategorized
A primer on how I use Linux.