UNIX Commands You Should Know
For Unix users, there are a ton of really useful commands that I think every programmer should know. Granted, I am still finding new shortcuts everyday, but for the beginning programmer, I think these should help simplify your life and will be immensely helpful in time.
$ cd fooToggles between directories. Also helpful to know that .. toggles backwards. Separate directories in your path with slashes.
$ lsLists all subdirectories within your current directory
$ cat foo.txtDisplays content of a file
$ cat foo foobar > foobar2Creates a new file foobar2, containing copies of foo and foobar in that order
$ chmodAlters permissions on files or directories using the system below:
User GroupsOperationsPermissionsu user+ adds a permissionr readg group- removes a permissionw writeo other= assigns a permissionx executes files accesses directories
$ mkdirMakes a new directory
$ historyBrings up a list of previous commands in your buffer.
$ sudo !!Re-runs your previous command as a root.
$ grep -r "foo"*Searches for text in all files in your directories and subdirectories.
$ grep output.txt *.cSearches within your code files for the specific file affecting the output.
$ service --status-all | grep firewallDetermines whether or not your firewall is running.
$ grep -n foobar foo.txtSearches for text within file and outputs line numbers where the text appears.
There are honestly so many uses for grep, but I think we can move on here. These were just some of the more common concerns I was able to find.
Note: This post was originally published on August 26, 2016. I’ve been migrating over a few articles from my old blogs.
