5 ms·
Linux Commands In Structured Order with Detailed Reference
- clintonc 13y agoI did not know about the "last" command. Very cool resource.
- chm 13y agoThis is especially great for newcomers. Sections 4, 5 and 15 are enough to boost a new user's confidence.
- yeukhon 13y agoOne of the most confusing yet important thing I learned as student from working with Linux is the execute bit on directory. It is important not to do chmod -R 755 mydir because you will give execution bit to files as well. https://www.washington.edu/computing/unix/permissions.html https://www.washington.edu/computing/unix/permissions.html
- thristian 13y agoGNU chmod lets you say *chmod -R a+X mydir" (an uppercase X) which, instead of giving everybody execute permission on all files and directories, will give everybody execute permission only on directories, and files that already have some execute bit set.
- e12e 13y agoThat's afaik not a GNUism: http://www.freebsd.org/cgi/man.cgi?query=chmod http://www.freebsd.org/cgi/man.cgi?query=chmod [edit: If I'm reading this right (I seldom have reason to look up Posix things, being generally concerned with concrete implementations) -- it's actuallly a BSDism that's been incorporated into Posix: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ch... ]
- ecma 13y agoThat's correct, +X was adopted from BSD into POSIX.2001. There's a paragraph in §Rationale about it.
- thristian 13y agoThe first draft of my comment started "GNU chmod, at least,..." but then I wound up with too many comma-delimited clauses and I dropped the qualifier to keep things readable. Thanks for looking up citations. :)
- seanhandley 13y agopushd and popd?
- gmjosack 13y agoI couldn't immediately tell from your reply whether you didn't know about pushd/popd or were mentioning them as something missing from the list. Since I don't seem to see them in the posted list I'm going to assume the latter. For anyone who is curious about pushd/popd, pushd will change your current working directory and adds your new working directory to the top of a stack. popd will remove the top directory from the stack and change your current working directory to the new top of stack. This is helpful in scripts where you need to change directories for some action and then back out to where you were. You can also use the dirs command to list the stack. One reason I could see omitting these from the list is that they are shell builtins rather than external commands as the vast majority of the list is.
- izietto 13y agoI use "cd -" all the time, it changes to the previous working directory
- gmjosack 13y agoYeah, whenever you cd, OLDPWD gets set to the directory you just changed from. cd will substitute $OLDPWD when you cd to "-". Perhaps even less well know, the shell itself will expand ~- to $OLDPWD so if you ever want to see where cd - would take you, or just list the files from your previous working directory you could do "echo ~-" or "ls ~-" respectively.
- oftenwrong 13y agoPWD, OLDPWD, and cd - are POSIX ~- is a bashism You can add a number to navigate the pushd/popd/dirs stack https://www.gnu.org/software/bash/manual/bashref.html#Tilde-Expansion https://www.gnu.org/software/bash/manual/bashref.html#Tilde-...
- 13y ago
- gmjosack 13y agoI'm honestly curious. Is a large portion of the Hacker News audience just less operationally experienced compared to the programming side of things? It seems like Linux 101 lists like this make it to the top of HN pretty regularly but I'd equate this to a post about Python that listed for/while loops, if statements, how to create a class, etc. Am I blinded by my own experiences or do very basic Linux seem to do very well on this site.
- elbear 13y agoI think that is the case. Even though the name is Hacker News, I suspect that most visitors are interested in the startup/business side of things, even though there is an important core of technical people.
- skeltoac 13y agoHow long were you involved with Linux before you knew everything in that list?
- serf 13y agotwo or three years as a casual user. a seperate issue : if you're going to make lists like this, please don't include distribution specific commands (like yum or apt-get) on 'linux' cheatsheets. they belong on redhat or ubuntu cheatsheets, respectively. Similarly irritating : the use of distribution specific package names.
- colechristensen 13y agoA good list will mention the alternatives (even if it doesn't explain all of them), but still include them. There are a lot of tasks which one ought to be familiar with which aren't anywhere near cross platform, and keeping your list to very widely available tools will leave huge gaps in your knowledge and makes for rather short lists.
- chadillac 13y agoI'm willing to bet there isn't but a handful of people in this community that "knows everything on that list", remembering everything on that list is... well, unneeded? 9/10 times when I'm using a command that isn't part of my "daily list" I'll need to consult man pages and/or Google. I've used xargs hundreds of times, but depending on when I used it last, I can never remember if I need -0 or not, and is it $1 or {} or wait, no no, I'm using awk, so it's $1, and I need to changes something... is it needle, haystack, replacement or... hell, I'm not even sure if it's substr or just sub... errrr. Not to mention some of these are distro specific, in some you use service name start, in others it's /etc/init.d/service start. Some it's adduser, others it's useradd, etc. It's relative to the distro a lot of the times... are the files in /usr/opt/ or /opt/... or maybe they're in /usr/local/opt/... Also they list stuff like locate, but not updatedb. Not a single mention of dd or shred or /etc/resolv.conf or netcat (I fucking love netcat!) or unzip (far more likely to need to unzip an archive than add a user in your day to day life). We're not command libraries, we're duct tape mechanics. http://xkcd.com/1168/ http://xkcd.com/1168/ edit: if you're interested in learning more... I honestly can't recommend this book enough. http://www.amazon.com/Linux-System-Administration-Handbook-Edition/dp/0131480057 http://www.amazon.com/Linux-System-Administration-Handbook-E...
- D9u 13y agoInteresting how many of those commands are not compatible with FreeBSD.
- ecma 13y agoI'm curious as to why the sheet recommends 'ps aux | grep' without bothering to mention the self-match (and tricks to avoid it like doing grep '[f]oo') instead of just presenting pgrep with the -f flag. This reads like a naive user primer rather than a particularly detailed cheat sheet. I'd highly recommend that anyone interested in improving their nix-fu beyond what is presented in the article look at something like the Unix toolbox[1] (which I personally still find useful and recommend frequently) and take the time to dig through the man pages in order to learn how to use and chain these tools. [1] http://cb.vu/unixtoolbox.xhtml http://cb.vu/unixtoolbox.xhtml
- JetSpiegel 13y agoThey even use pkill, so it would make sense to use pgrep as well.
- ama729 13y agoIMO "ps aux | grep" is better than pgrep, it's nicely formated and allow option like "--color", which allow to quickly find the option/process you were looking for.
- graublau 13y agoI'd love this for OS X.
- themodelplumber 13y agoFunny, I was doing some work in iTerm2 today and I found this really nice reference for OS X: http://ss64.com/osx/ http://ss64.com/osx/ "A-Z Index of the Apple OS X Command Line" The new one for me today was "ditto," which I immediately googled to see if there was a linux equivalent (there is, and it seems to be 'cp -Rp --parents src/ dest/'). Edit: Compared to the OP link I like that it doesn't truncate words arbitrarily to wrap lines :) Edit2: Lo and behold, a bash version: http://ss64.com/bash/ http://ss64.com/bash/ ...and a Windows version! http://ss64.com/nt/ http://ss64.com/nt/ I like to see that. Useful site, with more at http://ss64.com/ http://ss64.com/ (no relation to me)
- adestefan 13y agoI really don't like to tell people about killall. Mainly because it's burned people on non-Linux systems more than once.
- e12e 13y agoHm, no "lsb_release -a" under system? Also, I've come to rely more on ls -l /proc/${some_pid}/fd than lsof -- but if you only have to choose one, I suppose lsof is better.
- gmjosack 13y agolsof is much more useful when you want to see which process has a file open rather than the inverse.
- sparkie 13y agoI find it odd that the single most important command is absent from the list: man (w/ -k, or apropos). The article could really do with a section 0 to explain it. Armed with the ability to actually find commands and RTFM, you don't need to try and remember stupid lists of commands. Obviously it's helpful to remember commands, particularly frequently used ones - but you should start with the right mentality: that of being able to use your initiative to work something out, rather than resorting to google and not having to think.