strg + r
Linux
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
Who needs to remember commands when the shell can type them out for you :)
(Genuinely recommend it, it's been my daily driver for years)
It happens to you, to me and to every UNIX user since the 70s. Your system is (or should be) full of docs and tools to get help. One thing that I noted over the years, when we have new people at work, is that they don't known how to get help from programs or they don't known how to get help from their systems and when they struggle with anything, doesn't matter how basic, they go to the web for help. I always show them this: apropos
man
help
What was that command to compress files?
apropos compress
Oh! it was gzip
What was that command to do whatever with the GRUB?
apropos grub
Oh yeah! update-grub
What about that command to download files?
apropos download
Oh! it's wget
The next tip should be learn how to use and navigate in the man
pages, man have it's own man page;
man man
There are different sections, section 1 is the default, you don't need to specify, so you can just;
man bash
But if you want to get help from configuration files you should type;
man 5 sysctl.conf
Also, almost every program have a built in help compiled with the program code, you usually call it with --help or -h, sometimes just help and other times just call the program without parameters and it should print it.
Other people already suggest the cheat sheets, very useful especially for programas like vim or emacs, some of them come like a template to create a cube, so you print it and then craft it (like an origami) and you can have it in your physical desktop.
Last thing; be patience, your are in the rigth path, there's always more than one way to do things, you just need to find your own way.
I made a comment about how easy it was to learn VMS was (an 80s/90s OS). How do I print a file? I'll try PRINT. Okay, that works. How do I make 6 copies? PRINT /COPIES=6. Great! But how do I print to a file? I'll try PRINT /OUTPUT=filename. Well whaddya know!
I loved that OS like a brother. Sadly it eventually went the way of every proprietary system.
This reply made me smile. You are not going to believe me but I'm a millenian.... and I worked with OpenVMS (yes, you guess rigth, in a bank). May I tell you? Yes, sorry;
2012, first week as a SysAdmin in that hell bank, I made the mistake of saying "My fetish are old OS and computers" (this is true), "Well, we have this four VMS baremetal machines that nobody wants to touch and if they fail we fuck up all". After learning to be quiet and don't speak too much I found a VMS manual in TPB or some other site (I remebered downloading it as a torrent) and started using the pre ones (two of this machines where pre and two prod). I found that AWK was installed and a POSIX Korn Shell was sleeping there and nobody knew it, with only that I did a lot of stuff like Nagios custom monitoring (yes, this machines wasn't in the monitoring system, if there is not a red dot isn't broken) and automated things like the IPLs. I'm not going to say that VMS is a brother, but I feel comfortable with it even for a UNIX admin. The best part of this boring story is that, some months ago I was chatting with one old coworker that is stills in that bank, they still have this machines and they still use my shitty scripts for monitoring and getting data and statistics, can't believe (and a little proud of) that a OS that was developed before I was born is still up and running my programs.
Not a boring story at all, in fact it's Awesome! It's been so long since I touched VMS I would probably be lost now, but I wrote tons of apps and was a sysadmin for a couple years - which I really enjoyed, as 90% of that job was running backups and installing updates, leaving plenty of time to just play around. I missed writing apps, so I made a visual status monitor that let me look at running processes and pause, restart or kill them. My last exposure to VMS was when I worked at Fred Hutchinson Cancer Research Center in 2007 or 8 - a group there still had a VaxCluster running, but I never worked on it. Today there is still OpenVMS, mostly run on emulators by retro computing hobbyists I think.
Thank you!
I use a snippet manager called keep.
It runs in the terminal, and helps remember commands. I use it for remembering commands with lots of flags and parameters that i don't use often. But it can be used to remember any command you need.
You can also add comments to each command to remind you what it does.
I add the command i need to remember with
keep new
And when i forget it i can run
keep list
To get a list of commands.
It can do more, but i've only ever used those two functions.
Use GUIs for all the things.
Linux users are obsessed with the command line because it's faster if you can type fast and remember everything. If you can't, GUIs are actually much much faster because you are visually guided towards what you're looking for and have to spend little time looking for the correct commands and syntax and everything.
because it’s faster if you can type fast and remember everything.
No. That's just wrong. You only need to type ONCE and you don't have to remember it all, that's why reverse-i-search
(aka Ctrl-r) is so powerful. It allows you to search within your command history so you only need to remember few letters of the command (which you can annotate, e.g. commandname parameter #it does this
) and can even edit after, e.g. changing parameters.
But, more fundamentally, that is NOT the point of the command line!
The whole point of the command line is... to be able to repeat things, namely to script actions that can be customizes and combined to YOUR unique needs. So it's absolutely not about typing speed or memory. In fact, once I do have a good command, what do I do? I save it as a script precisely so that I do NOT have to type it again. Think of commands as Lego bricks that can be combined to together, build on top of. That is basically impractical with GUIs. Sure there are some tools to automate the click on GUIs but it's unreliable, nor can it be easily shared.
PS: I'm not saying anyone should use the command line over GUIs. I'm not being prescriptive. I'm only trying to clarify what the point of the CLI is.
TL;DR: command line is about combining tools to your unique needs, repetitively and reliably.
This is so true.
I have been using Linux since the mid 90s. Exclusively since about 2005.
I am obviously getting old now. But my willingness to remember the structure of rarly used commands/options. Has always been limited. If its not something I do often. It generally involves looking up man pages. And more often then not a GUI is just faster.
GUI has improved hugly in the time I have been using Linux. To the point that now it really is quicker if I'm not already in the terminal.
But as soon as things get to the multiple command level. Or complex enough that looking up is needed anyway. Typeing is just faster. Being all in one window makes a huge difference. But also once things get to the need to look up point. Command lines are just easy and quick to share online etc. So it tends to be the easy way for forums etc to share guidelines etc.
For all GUI has improved. Text is still one of the easiest ways to share data. It allows things to be organised and jumped around from point to point.
I am teaching an ex GF to use a new Linux PC for the first time. (Put it together as a wedding gift)
I tend to tell her to switch between GUI and command line as best suits her. As long as you understand the goals of each step write or wrong is whatever seems easiest for the user.
But it is important t to become comfortable with the terminal. Because this is how others will share info. And she will need to be able to understand what they are telling her to do.
Online trolls still exist. So understanding things like
sudo rm -rf /
Is essential before typing it.
teaching an ex GF to use a new Linux PC for the first time. (Put it together as a wedding gift)
very cunning revenge!
Find a cheat sheet. There are hundreds out there -- you probably want one for basic terminal commands, and one for whatever package manager you're currently using.
The history command is also great if it's something you do fairly often, but not often enough to remember clearly.
Use Fish (very good autocomplete) and aliases
I have around 10 "linux extract tar archive" online searches last year alone.
Exactly!
I think 90% of the comments here are “write your own notes“ - which is possibly over simplistic.
Everyone's different but IMHO:
The brain is better for imagination than long term storage. So if you're stuck trying to remember some obscure command(s), it's just better to use something else to store that on.
But when the brain understands the core concepts well enough, the details come together as habits (where repetition comes in).
So, if you're unable to recall something, take some time to think / remind yourself about the underlying concepts and why that's the command - next time it'll be easier, eventually it'll be effortless.
I had to learn some strange concepts for work during a deep technical troubleshooting session on a client's system and the commands were like just facemashing the keyboard... I've no idea what those commands are now (written down), but I can recall what / why I was doing them and that was the key... for me.
(Using computers since '80s)
But when the brain understands the core concepts well enough, the details come together as habits (where repetition comes in). This is the way. Understanding core subjects then is easier to connect and recall stuff.
I suggest having a GNU command cheatsheet set as your wallpaper or getting a Linux cheatsheet deskmat.
Repetition is key and eventually you will get the hang of it.
Idea 1:
Print out some of the various CLI cheat sheets and pin them to your wall by where you work on your computer.
Maybe this one:
Then, print a page with commands you commonly use, either with more complex syntax or that aren't on the sheet. (Like, "ls" is on there, but "ls -s -h" is not, for example.
Idea 2:
Write bash scripts to automate some of your commonly used tasks. Comment them. Imagine someone else is going to have to use them, even if you're the only one who's ever going to look at them. Not only will this help you learn lots of commands and force you to describe what they do (which will help you retain the information), it will be there as a record of how it works that you can go back and look at months or years later, to remind yourself how to do something.
Yes, write automation. This will lead you to learning new commands that solve problems as you go. Debugging until they work correctly also helps make them more familiar. This is the best way to learn for sure. At least in my own experience, could be different for you, but I strongly suspect this’ll work well.
The gorilla bash llm thing has been immensely helpful.
Amazing, thank you
You can make a cheatsheet and keep it on your desk
I just use guis
My solutions are:
- Just arrow up until you find the command from last.
- Learn to use CTRL-r and search for old commands.
- Bash completion helps with arguments
- Save stuff in shell scripts
tldr is good for remembering how to use a command, once you find it.
Unless you want to increase productivity in specific field (say some kinds of software development) you won't even need to remember anything more than cat, ls etc. In those specific usecases you'll become habituated to the command you use frequently, nobody becomes a grep ninja on day 0.
Whenever I need something mildly complex with ffmpeg or imagemagick, the right command is just a web search away, I rarely remember syntax of these anyway. I find commands less obvious and harder to find for windows shell (technically powershell is cross platform btw), but maybe that's because I'm not much familiar with windows-ism'
Tip: whenever you encounter a useful command syntax/one liner, save it with brief description. I find konsole's built in quick commands quite handy, some other terminals probably have such features too. Otherwise a simple markdown list is enough.
You could make aliases that are easier to remember for you.
If you e.g. had trouble remembering that mv
does a rename, you could alias rename=mv
. Ideally just put whatever you would have googled in "linux command to x" as the alias.
That's the power of Linux; you can tweak everything to your preferences and needs.
Wild had no idea—this is so cool. If you do this, does the original command also still function (so like I could rename to something easier for me, but hopefully transition to the real deal at some point/ properly follow help forums or suggested pasted commands)
The originals remain untouched.
It is possible to override existing commands with aliases though. This is useful for setting flags by default. I have alias ls='ls --color'
for instance such that whenever I run ls
, it actually runs ls --color
, providing colourful output.
Note that aliases are only a concept within your command line shell though. Any other program running ls
internally won't have the flag added and wouldn't be able to use any of the other aliases either (not that it would know about them).
It's very easy to program your own "proper" commands though on Linux. If you had some procedure where you execute multiple commands in some order with some arguments that may depend on the outputs of previous commands, you could write all that as a shell script, give it some custom name, put it in your $PATH
and run it like any other command.
Also very cool—the building in default modifiers to the command. Thanks for the great tips.
First of all, we are ALL in the same boat. Newcomers from whatever OS to professionals alike, we all struggle to remember commands and their idiosyncratic syntax.
Now that this is out of the way, namely that you are not "special" in having difficulties there, a little challenge. How do YOU normally do when you are learning something new? Typically when people do that, e.g. at school or while doing a professional training, they take notes. Are you doing that? I know it might sound "strange" but learning Linux is... well fundamentally learning so yes you can use whatever tools and techniques for that too. So... here are MY notes https://fabien.benetou.fr/Tools/Shell which will probably be rather pointless to you but at least prove that I'm not suggesting something I didn't try first.
TL;DR: yes, use all the tools & tricks recommended here (IMHO with reverse-i-search first) but don't forget to actually take notes!
Thank you! i will check them. Yep im a long time user of Obsidian and i have notes everywhere. But going to them , when i dont have much free time to spend, it also feels like a tool would be amazing to simplify the get into complex command.
It's a balance, namely you are probably wasting time if you jolt down literally everything... but also what you don't write down and forget, have no way to backtrack, will also waste time.
IMHO it's the process itself that matters, namely that by taking the time to write down, organize, lookup, you gradually have to do it less and less because you are more conscious about what you know, what you don't, and adapt accordingly.
If you do find a better way, based on a tool or not, please do share back!
Use fzf to complete commands, use cmd line helpers like 'tldr'
history | grep command you're searching for
That will return all commands you've typed that contain that keyword. Helps if you remember part of a command, but can't remember the specific flags or the proper format.
If there are common commands that you use over and over, turn them into a Bash script and name the script something descriptive.
I do that for long commands that I don't want to type out, like my whole system update workflow: sudo apt update -y && sudo apt upgrade -y && sudo flatpak update -y
I saved that as a Bash script and called it "update.sh" then I saved it in my home directory. Now whenever I want to do a full system update, I just type ./update.sh and it asks me for my password, then updates my whole system without me having to do anything else. I do this with several different tasks like my remote Ansible server updates.
Other than that, you can buy/make a linux command cheat sheet with the most common commands. Keep it with you or next to your computer. Look at it whenever you need a refresh.
I remember the basic filesystem commands like ls, cp, mv, rm, cat etc, but I generally don't remember much more than that. Even so, I still use the GUI file manager/software center pretty often, there's no reason why I have to force myself to use the terminal all the time.
I have an app on my phone to search for commands that I barely use and don't remember. Don't worry that much about it if you aren't a professional system administrator or other such jobs.
Here is my personal approach to this.
-
I have set my bash history to a ridiculous 1000000 max length, so that I can use CTRL+R to search for commands that I have ran before
-
I write down a lot of commands in a searchable note text document
-
Ask chatGPT
-
Use the
tldr
command -
Added A LOT of verbose custom aliases and scripts. For example instead of
inotifywait -m -r --exclude "(/tmp.*|/var/cache.*|/dev/pts/|/var/log.*)" -e MOVED_TO -e CREATE -e CLOSE_WRITE -e DELETE -e MODIFY .
(nobody can remember that alphabet gibberish)
I just type watch_for_changes .
Since it is verbose, straight from my brain, I always remember it and it works with autocomplete. I have like ~30 such commands so far.
repetition...repetition...repetition...repetition...repetition...repetition...repetition...repetition...lol
Repetition is key. If you do it enough you'll remember it.
I recommend to installed starship, fish and ZSH. I just tried them recently with config files from a friend and am pleasantly surprised:
I partly remember the first letter and press arrow up.
I use ZSH shell with oh-my-zsh. It autofills the rest with history at the point you write. So arrow keys make you scroll through the history which is beginning with the thing you wrote
Back in the ancient pre-Internet days I worked for many years with a system called VMS made by Digital Equipment Corp (aka DEC), now long gone. VMS was a dream to use - every command and option was an actual word, and you could abbreviate commands and options any way you wanted, As long as you were unambiguous, it would figure out what you meant. So easy to learn, and felt so natural. Based on that alone I thought VMS would become more popular than Unix, with its cryptic commands, and those single-letter options that are sometimes the first letter of something obvious and other times seem totally random. But internally VMS wasn't structured as well - for example, piping output from one command to another was possible, but it wasn't geared for that like Unix is. There was also no free version of VMS, and it only ran on DEC hardware, so not that many people even knew about it. The dawn of Linux for PCs was essentially the nail in the coffin for VMS. But I do miss that CLI.
Use ctrl-r a lot (navigate up/down with ctrl-p and ctrl-n) and try to "fuzzy-match" previously used commands.
There is a very useful command called fzf
which, while only a search program at heart, can be configured to complement this nicely.
you don't need to remember anything, except commands you use the most often but even then it becomes muscle memory after a while. If you ever need some specific command to use, just look it up online.