UNIX Commands You Should Know

Sharon Lin
Aug 9, 2017 · 2 min read

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 foo

Toggles between directories. Also helpful to know that .. toggles backwards. Separate directories in your path with slashes.

$ ls

Lists all subdirectories within your current directory

$ cat foo.txt

Displays content of a file

$ cat foo foobar > foobar2

Creates a new file foobar2, containing copies of foo and foobar in that order

$ chmod

Alters 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

$ mkdir

Makes a new directory

$ history

Brings 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 *.c

Searches within your code files for the specific file affecting the output.

$ service --status-all | grep firewall

Determines whether or not your firewall is running.

$ grep -n foobar foo.txt

Searches 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.

Sharon Lin

Written by

Computer Science @MIT | Software security engineer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade