r/AskComputerScience • • May 23 '21

How vital is knowing command line to succeeding as a programmer?

I enjoy programming, but the unfortunate truth of the matter is that my memory is awful. This is especially problematic when command line comes into play. It takes me probably 5 minutes to figure out even the most basic commands, and it takes half as long to forget them again. I don't know why this is such an issue with the command line when I don't have any such issue learning programming languages, but I do. Is not knowing how to use the command line going to be a significant handicap when it comes to succeeding as a programmer? I've never really understood why some of my old professors would always use the command line to run programs when they have an IDE that could do the same thing with the press of a button. Is there some additional advantage that I'm not seeing?

46 Upvotes

28 comments sorted by

42

u/jhaluska May 23 '21

Command lines work better on remote systems.

My advice is you should just get used to making cheat sheets for your future self. Treat the command line like code that you put a comment above in your cheat sheet and you'll be fine.

11

u/virtua_golf May 23 '21

I’d say it’s close to impossible to work on remote systems without command lines. Not only would accessing a server and restarting a service take significantly longer, you’d have to allocate memory and storage for a desktop environment on each system. Okay, so not impossible but all downside and no upside.

14

u/roman_fyseek May 23 '21

You can write scripts when you know the command line.

14

u/sepp2k May 23 '21

I've never really understood why some of my old professors would always use the command line to run programs when they have an IDE that could do the same thing with the press of a button. Is there some additional advantage that I'm not seeing?

You can't automate pressing a button (I mean you can, but not as easily and not on systems where the IDE doesn't run in the first place). I mean if you don't know the commands to build your project on the command line, how do you set up your continuous integration server for example?

28

u/spaztheannoyingkitty May 23 '21

tl;dr: Yes, the command line is very important. It's important because it will always be able to do more than your IDE. It's often faster and/or more effective to do something on the command line. I won't include any specific examples here because I don't want to get bogged down with pedants.

As for learning it: it takes practice. I recommend finding a good cheat sheet and keeping that available (bookmark it, print it out, whatever works best for you)

Assuming you're using linux, here are a couple of examples:

https://cheatography.com/davechild/cheat-sheets/linux-command-line/

https://www.linuxtrainingacademy.com/linux-commands-cheat-sheet/

https://www.educative.io/blog/bash-shell-command-cheat-sheet

You might even consider making your own cheat sheet by including commands you find yourself needing.

4

u/mplang May 23 '21

Yes! Practice is critical for learning, remembering, and improving. For me, whenever I want to really learn a new tool (or whatever) I do my best to use that thing exclusively (insofar as it's appropriate for the task!).

So, want to get good at the command line? Live in the command line!

5

u/cheeseisakindof May 23 '21

The command line is super important. It's very helpful to be able to switch from coding a program, to running it, to running other tools like gcc, gdb, to checking system performance, etc. Basically everything can be done via the command line. And once you get really good, you can learn how to write shell scripts to issue sequences of commands for you.

It was similar for me when first trying to get into it; I often felt like I was memorizing the commands. Just keep using it and keep learning the small ways it can help you and improve your workflow. Take some time to learn the Linux file system (I'm assuming and hoping you're using Linux for programming) and the basic UNIX commands (cd, mv, cp, etc).

You might wanna check out Linux Journey, it's a simple interactive website for learning Linux and practicing with the command line. Additionally, you might wanna check out r/linuxupskillchallenge. It's a sub that, every month, starts a new Linux course that goes over some basic Linux sysadmin stuff. It will teach you how to use SSH to remotely log in, download software from the command line, compile and install that software, and even set up a super simple web page. Learning Linux and how to do anything from your command line will truly help you excel as a programmer.

5

u/discoFalston May 23 '21 edited May 23 '21

You’re going to run into it in your career.

I have a similarly terrible memory, here’s what helped me

  1. Aliasing. If you often run a command with a lot of flags you can “alias” it — example alias gr=‘grep -Rn -I —color=always’. Now ‘gr’ replaces the ‘grep’ with all the flags

  2. Keep a cheat sheet in your home directory and have an alias to ‘cat’ it whenever you forget.

5

u/pragmaticSloth May 23 '21

Well. You don't need the command line to be successful, but it just makes things easy.

If you want to automate something you just use bash and commands that run on the shell, or python if you prefer. Don't worry about forgetting commands, while I was a student, I only knew the basic ones. Once you start programming in the real world, you will memorise the commands automatically. The ones you need to use at least.

The best thing to do while a student is just exploring Linux, make sure you know how to build a bash script and run it. Later, that knowledge will pay off. Even if you don't memorise the commands, you can always ask google and knowing how to ask google is basically the same.

1

u/bitlockholmes May 24 '21

Yes you do lets be real

You cant even do front end without understanding linux to some extent

1

u/pragmaticSloth May 24 '21

I am curious. Can you elaborate a little bit on why a front-end dev will need to understand Linux to some extent?

1

u/CoopNine May 24 '21

There's a good chance you are deploying your front-end app to a linux container. If you're using AWS as your host, that is likely your backend. The exception would be .NET development to windows hosts, but that is less and less common these days. And lets be honest, we're asking our devs to be full-stack at least in some capacity today. Maybe not an expert, but at least functional on the backend.

1

u/bitlockholmes May 27 '21

Exactly. Who is going to pay for someone who focuses solely on deigning the page, and cant be arsed with understand how it's delivered in some capacity. How are you supposed to understand how to link your components together if you cant understand how they are delivered.

3

u/[deleted] May 23 '21

i just alias everything to be more memorable. but generally if you keep using the command line youll get used to it and remember it. command line is cool because you can programmatically do stuff. eg you can run a program by opening and IDE and pressing run, but say you want to run 100 programs, opening 100 times is long and tedious, but in the command line you could just run the compiler/interpreter on all files in a folder or all files that start in a or whatever condition you want.

2

u/[deleted] May 23 '21

Very vital. But if you do'nt like the command line interface maybe check out Git Bash.

2

u/BUNDLE_OF_STICKS_AMA May 24 '21

From my personal experience I have developed command line skills as a byproduct of working on other projects. During development you run into things either with your development environment or testing that requires using the command line. It was hard for me as well to understand what I needed to really remember or not. Best advice is to pick a project that you will be passionate enough about to complete and go for it. You will find command line necessities along the way.

2

u/bonestormII May 24 '21

Just write a program in Bash of medium complexity, and it will help a lot with the basics. To be honest, the main difficulty is understanding file descriptors, and how text parsed/expanded by the shell, and then by programs you are calling. Those two things alone, coupled with basic bash proficiency, will give you a solid underpinning.

However, the command line is not a perfectly unified singular interface. While it is a dynamically scriptable environment, its primary function is to call other programs. Programs define their own argument structures, what file descriptors they read/write to, how they handle logging, what exit statuses mean, etc. There are conventions, but these things are not perfectly consistent from program to program. As long as you understand the principles and can script comfortably in bash, you will simply need to become quick at looking up arguments in man pages.

The main difference in the shell environment from another dynamic scripting language like python is the scope and domain of the problems you are trying to solve. The typical domain and scope of a program might be like "get data from some source, take user input, mutate the data in memory, write it to a file or a socket, and provide confirmation for the user". The domain focuses on data and object representations in memory, and the scope is generally processing that information and handling user interaction.

But what if you want to perform that task every Sunday at 12:30 PM, and after you are done you want to save a report to some network mount? It's somewhat opinionated to say this, but many people would say that kind of personalized, implementation-specific thing is better suited for a shell script than to be coded into the program itself. This perspective is very tied to the Unix philosophy of programs being relatively small and focused in their scope, that they should "do one thing well". Working in this way allows you to design your programs as tools in a flexible tool chain of programs that interoperate together using the shell as the interface. Not every program is appropriate to think of in this way, but I think it is highly effective when your domain space involves administration of system resources or coordinating/gluing many programs together.

Also, as a programmer, you may want to design programs that use things like background services/daemons, many of which may communicate over networks, and those are things that ideally by their definition should not require a dependency on something like a window manager, as these types of programs frequently run on headless servers. That being the case, the only reasonable way to access, run, monitor, and analyze such programs is using the command line.

2

u/Tai9ch May 23 '21

Yes, learning how to use a computer is helpful to programming a computer.

No, pointing and grunting with a mouse doesn't count as knowing how to use a computer. That shit changes every time any new version of any program is released, rarely follows any useful patterns, and hides 95% of what's happening.

1

u/IAmNotNathaniel May 24 '21

I'd also add that the amount of IDEs that cover 100% of the available command line commands and all their options is probably zero.

1

u/Zdrenka May 23 '21

I find the command line very useful, but I work with very good programmers who don’t use it. Basic knowledge of it helps but there are plenty of GUI alternatives, I wouldn’t worry about it affecting your career.

2

u/Objective_Mine MSCS, CS Pro (10+) May 24 '21

It also depends a lot on what kind of development you do.

Some languages and platforms have much more GUIified tooling. If you do e.g. server-side Java development on Windows and someone else is taking care of the servers, you might end up doing mostly everything with the IDE and GUI-based management tools anyway. For example large non-tech corporations or organizations might well have those kinds of environments. I've seen it in the public sector.

The same is probably even more true of C# development although I have no experience with that. I imagine Windows desktop app developers might also have tooling mostly not based on command lines

If you do development in a more unix-oriented language or in a less Windows-oriented or just otherwise less rigid environment, not being able to use the unix command line might become much more of a handicap.

1

u/Ragingman2 May 23 '21

I highly recommend getting familiar with scripts, aliases, and command line history commands. Usually within a given project you will only have a couple commands that you need to run. If you take an afternoon to write up a script that does "build the project, copy it to the development server, kill the old version, start the new version" (or whatever your project's equivalent is), then you'll A. have a script to use for most work, and B. have a place to look when you need to remember the commands.

Aliases give you shorthand commands for things you would otherwise use then forget / that you don't want to type out too often.

Setting your bash history to "forever" and getting used to reverse search means that once you've figured out how to use a command once you'll be able to find it again later.

1

u/0x68656c6c6f May 24 '21

Yes, command line tools are important to know, but no it's not important that you remember everything.

As you get more experience you will remember more. For anything I don't do regularly I will google to get the exact syntax and flags for what I want to do.

And as others mentioned, keep a cheat sheet handy of common commands. If you have to look up how to do something, add it to your sheet.

1

u/theGentlemanInWhite May 24 '21

Using a command line is the best way to have complete control over your system. You may not need it, but you will constantly be outshone by those who do use it.

1

u/proskillz May 24 '21

It's very important and I wouldn't hire you if you couldn't at least use it proficiently.

1

u/CoopNine May 24 '21

With the increase in importance of CICD and containerized deployments it is more important than it was 10-15 years ago. People who struggle with the command line struggle with a lot of things that should be trivial.

1

u/ghjm MSCS, CS Pro (20+) May 25 '21

You say you're good at learning programming languages. So learn bash scripting as a programming language. Then you'll know how to use a command line.