this post was submitted on 09 Aug 2023
61 points (94.2% liked)

Programming

17668 readers
217 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
all 36 comments
sorted by: hot top controversial new old
[–] somegeek 84 points 1 year ago (3 children)
[–] [email protected] 18 points 1 year ago (2 children)

Also, the fact that most common use-cases are very common makes using the command line very google-able. Oh, you need to create thumbnails from a folder of 10000 video files, then rotate, crop, rename and archive them? Guess what, you are not the first.

[–] Zink 8 points 1 year ago

This is the best part about it for me. It’s like finding the perfect code snippet or example for what you’re trying to do, but for all kinds of stuff on your computer and not just inside whatever project you’re working on.

I’m not any kind of command line guru, but the terminal is the first thing I open any time I fire up one of my VMs.

[–] CodeMonkey 1 points 1 year ago

Also, when you find a script try to understand what commands they are using and with what flags.

[–] [email protected] 15 points 1 year ago

This is really the only answer. You will always be afraid to use something you are unfamiliar with or don't trust. Command line is very useful and quick once you learn it.

[–] GJdan 5 points 1 year ago

This. I used to also keep a notebook with me and jot down the commands I used often. Eventually I learned other ways to jolt my memory and learned to use man. As time went by I used my notebook less and less.

[–] philluminati 28 points 1 year ago* (last edited 1 year ago) (1 children)

Ultimately it helps to understand the benefit of the command line: That text is a more effective mechansim for communicating that anything else. That any command you learn can easily to turned into a script an automated. That commands can be copied and pasted and shared with friends much easier than videos or images. Knowing it's benefit motivates you to learn it.

Look at the explanation in Windows for how to change a registry key or how to change a printer setting. It's one long guide full of screenshots thats painful to follow or understand. Where-as Linux users can easily share commands and fixes or tests over a simple irc chat, because the command line reaches the whole system.

The command line is of course a place where lots of apps can be plugged together and mixed up to achieve hundreds of goals, and thus learning awk, grep, sed, wc means you can count, search or perform regexes on any other part of the system, from counting users, or essays, to network connections, or processes or anything.

To be honest, many existing blogs answer exactly this question, which has been asked a million times before.

[–] Redkey 5 points 1 year ago* (last edited 1 year ago)

I agree with most of what you said, except for the Windows examples. The pages that you linked begin with three-line TL;DRs that are enough for any barely-competent user to find and modify the necessary settings. While the full instructions may be tortuously detailed, are they actually hard to understand?

And sure, those Windows pages don't advance the user's knowledge in any meaningful way, but neither does blindly copying and pasting a line of shell commands.

By the way, while I appreciate that we're talking about if and how CLI is superior to GUI, and not Linux versus Windows...

Where-as Linux users can easily share commands and fixes or tests over a simple irc chat, because the command line reaches the whole system.

... both of those tasks can be done via CLI in Windows, too. I am very happy that I switched to Linux, but there's no reason to misrepresent the other guys.

[–] ndotb 14 points 1 year ago (1 children)

throw yourself to the wolves

embrace the wolves

[–] [email protected] 8 points 1 year ago (1 children)

Befriend the wolves.

Date the wolves.

[–] [email protected] 7 points 1 year ago

Fuck the wolves

Cuddle the wolves

[–] [email protected] 11 points 1 year ago (4 children)

I am using ZSH, that function that allows you to type part of the command and then do UP key to find previous command starts with same prefix is killer function for me.

(I don't know if this function is added by oh-my-zsh or not.)

[–] Mikina 4 points 1 year ago

ZSH is amazing. I'm unfortunately mostly stuck on Windows, and I didn't find any similar alternative for win shell, but ever since I tried the ZSH configuration that's default in Kali Linux, I've been hooked on ZSH.

[–] philluminati 4 points 1 year ago (1 children)

Bash has Ctrl+R which is a similar feature.

[–] cd_slash_rmrf 3 points 1 year ago

zsh has ctrl-r as well; this feature is specifically for beginning-of-match and some find it a bit more ergonomic.

[–] learnbyexample 3 points 1 year ago

You can do it in Bash as well. Put this in .inputrc:

"\e[A":history-substring-search-backward
"\e[B":history-substring-search-forward

# or, if you want to search only from the start of the command
"\e[A": history-search-backward
"\e[B": history-search-forward
[–] [email protected] 3 points 1 year ago

TIL. I wish I knew all the features of ZSH. Just the git shortcuts are amazing

[–] Redkey 9 points 1 year ago (1 children)

One thing that wasn't mentioned in the article is default settings. In so many CLI programs (and FOSS in general), there seems to be some kind of allergy to default settings. I don't know whether it's a fear of doing the wrong thing, or a failure to sympathize with users who haven't spent the last three months up to their elbows in whatever the program does. But so often I've come to a new program, and if I've managed to stick with it, come to the realization later that at least half of the settings I needed to research for hours and enter manually every time could have been set to static defaults or easily-derived assumptions based on other settings in 99% of cases. Absolutely let your users override any and all defaults, but please use defaults.

I'd also be interested in the overlap between people saying, "LOL just get gud" about using the command line, and people who are terrified of using C++.

[–] zemja 1 points 1 year ago

I feel the same. I don't like how people always recommend starter kits to Vim/Emacs beginners, for example. I think they'd actually learn something, if, at first, they did things the intended way.

[–] [email protected] 8 points 1 year ago (4 children)

Progress indicators. Typing out a long command only to have it just sit there with no report is frustrating.

[–] [email protected] 9 points 1 year ago* (last edited 1 year ago)

Depending on what one is doing, placing pv in between (usually with -s to specify size of data if known in advance) gives a progress bar, with speed and size of data passing through.

Say you have an SQL dump of 1048576 bytes:

cat dump.sql | pv -s 1048576 | mysql somedb

and now you know how far it is instead of just waiting :)

[–] agilob 3 points 1 year ago

On BSDs you can do ctrl+T and it prints progress, there were plants to implemented this on Linux, but it didn't get enough traction.

[–] [email protected] 1 points 1 year ago

even a spinning icon would be nice. It's hard to tell if I should kill something or if it's still in progress / finishing up

[–] [email protected] 1 points 1 year ago

I'm about 20% competent in Linux so thank you all for the comments. I pretty much dabble and spend a lot of time using snapshots lol

Saving this post!

[–] [email protected] 5 points 1 year ago* (last edited 1 year ago)

Growing up with limited capabilities (e.g. sh or ksh on headless SunOS/Solaris and AIX servers) and a lot of room for failure is what did it for me. I learned to think before typing, break things and fix them again. I still learn that way and I find that life without crutches and with lots of tinkering improves my understanding of how most things work and makes me more efficient in the long run.

Also man pages.

[–] [email protected] 5 points 1 year ago (1 children)

Use it inside a VM. Worst case you can restore a snapshot or just reinstall. No risk of not being able to boot

[–] [email protected] -1 points 1 year ago

Have backup of your data; replicas are not backups.

That's the one rule you must follow... For basically everything. There's no need for a VM, there's need for backups. Also, if you don't want to learn the command line right now, you need backups too.

[–] [email protected] 5 points 1 year ago

Write a shell script, for example, a script that uses rsync to back up your computer to another over SSH. Then make it rotate your old backups.

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

I'm a unique case because my first foray into Linux was using the CLI via SSH on a server, and I thought the CLI was insanely cool and was immediately hooked. So I don't really have any good advice other than to just force yourself to use it I guess?

Ironically, I have a more difficult time using desktop Linux just because it's not a headless environment like I'm used to. I still use it ofc.

[–] [email protected] 3 points 1 year ago

Fish made me love the Terminal

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago)

i deleted my gui file manager and text editor. worked pretty well