57

I am new to Linux, and being dyslexic, find working from a command line a challenge. What aids or advice is available to help work with this issue?

16
  • 4
    When you drag a file into the terminal it automatically prints the complete path. When you press the up arrow key it automatically prints the last command.
    – karel
    Feb 11, 2018 at 15:55
  • 22
    It's a good question, but I find it hard to imagine what your problems are. Please edit and explain what exactly challenges you most. Possible solutions may be simpler than you think (see other comments).
    – dessert
    Feb 11, 2018 at 15:55
  • 6
    Keyboard shortcuts help a lot, find useful ones here: askubuntu.com/q/45521/507051 and askubuntu.com/q/444708/507051
    – dessert
    Feb 11, 2018 at 16:05
  • 4
    To save time typing a long path to a file I drag the file's icon into the terminal to print the file's path and then copy/paste it into the next command.
    – karel
    Feb 11, 2018 at 23:50
  • 3
    Zsh can actually autocorrect swapped letters in command names! (The manual pages have more information.)
    – SilverWolf
    Feb 12, 2018 at 0:14

8 Answers 8

90

You may try a few to things to improve your experience with the command line.

  1. Use tab completion (automatically fill in partially typed commands by pressing Tab) whenever possible.
  2. Press (up arrow key) to automatically print the last command, and keep pressing & (up & down arrow keys) to cycle through the command history.
  3. Drag a file into the terminal to automatically print the complete path.
  4. Press Alt+. (dot) to insert the last argument from the last command you executed (useful for e.g. mkdir followed by cd).
  5. Use keyboard shortcuts (see this and this).
  6. Use Bash aliases (see this and this).
  7. Use history, you can view the command history and then use the number of the historical command to re-execute the command (e.g., redo command #352 with !352). Alias it to simply h for quick and easy access.
  8. Use a reverse terminal search (Ctrl + R, then start typing) to match earlier commands; it's a quick way to find things from earlier.
  9. Use a shell that completes commands and optional arguments such as Zsh or fish.
  10. Use a font which increases readability for readers with dyslexia, e.g. "OpenDyslexic", in Terminal.
  11. Hear what is on the screen as you are reading; enable a screenreader like Orca. You can have it read just one word, a whole page, spell out words letter by letter, change speed, volume, level of detail, etc.
  12. Enlarge a part of the screen as you are reading; take a look at apps that zoom with keyboard shortcuts, like Magnifier.
  13. Advanced: personalize the way the output displays, like setting conditional text colors. The default Ubuntu distro provides several enhancements to Terminal. When you use ls to list contents of a directory, for example, subdirectories print in blue and filenames print in white, making it easier to distinguish the two. For other examples, have a look at the many personalizations people have shared. Some are sure to be worth trying out "as is". One good starting point is the popular Awesome dotfiles repository.
3
  • 1
    @flith It's supposed to be !352 instead of history 352, innit?
    – pomsky
    Feb 12, 2018 at 14:43
  • 2
    I have so far changed to the dyslexic font, and enabled colors in terminal. That has helped with reading and the headaches some. Still plowing through the books Ubuntu Unleashed, and Linux Bible. Vim and some of the other editors may provide some answers. Feb 14, 2018 at 10:33
  • 1
    Ctrl + R - I've never seen that before. That's amazingly useful
    – Noel Evans
    Sep 6, 2019 at 8:35
16

I will attempt a comprehensive answer. If I left something out, please comment and I will add it.

Tab completion

Tab completion is your biggest help here. Pressing Tab will complete the command as as far as is uniquely identifiable. Pressing Tab twice will give a list of options. Typing enough caracters to Identify which option you want and pressing Tab again will complete it. This also works with path/file names.

For example, let's say I have a user named Paul, and he has the file text123.txt and text124.txt in his Downloads folder:

I could type /h Tab and bash will give me /home/. Then type P Tab and get /home/Paul/. And continue in this fashion until I have the complete file and path.

Path/file name expansion

Auto-completion also accepts wild cards * and ?. ? matches a single character, and * matches all characters (or none). Using the above example, I could type:

/h*/P*/Dow*/t*4* then Tab and bash will give me /home/Paul/Downloads/text124.txt. If I am sure that I am matching the correct file, I can just hit Enter to execute the command with out expanding it first.

Some common directory references are:

  • ~ for your home directory.
  • .. parent directory
  • . current directory; in case you want to absolutely sure that bash looks in the right directory.

Keyboard shortcuts

The up arrow and down arrow keys lets you navigate through a list of recently used commands. Press Ctrl+G to escape from history searching mode. Alt+. repeats the last argument of the previous command.

Aliases

Bash allows you to specify aliases. If you find that you often mistype a command the same way, you can add custom aliases by editing ~/.bashrc and adding lines like this:

alias agi='apt-get install'
alias mkdri='mkdir'

Then relogin to activate them.

7
  • 4
    ~ is not an alias, it's rather expanded by bash as described in EXPANSION/Tilde Expansion in man bash~ is expanded to $HOME, ~+ to $PWD and ~- to $OLDPWD for example. You can actually set e.g. alias ~='cd ~' and it's very useful to quickly return to the home dir, but that's totally different from (and doesn't hurt) the expansion.
    – dessert
    Feb 11, 2018 at 21:22
  • Well, man bash has a whole section EXPANSION… You already covered a bit of pathname expansion.
    – dessert
    Feb 11, 2018 at 21:28
  • On my system I can't seem to get most of the other expansions to work in CLI. But I'll reorganize to fix the tilde explanation.
    – ravery
    Feb 11, 2018 at 21:55
  • 1
    @WJAndrea: The shell does have some special support for .. and .; for example, cd .. actually removes the last path segment from the present working directory, rather than adding a .. segment.
    – ruakh
    Feb 12, 2018 at 6:34
  • 1
    @WJAndrea and ravery: Ctrl+G exits the command history search which you start with Ctrl+R. Once started, just type the beginning of a command and it will show you the most current matching one. Leaf through the matching commands with Ctrl+R, run a command with Enter or edit it with a key that changes the cursor position, e.g. Home, End, arrows etc. This search mode is extremely helpful if you want to find a recent command by its name – try it out, it'll blow your mind. ;)
    – dessert
    Feb 14, 2018 at 8:16
12

The Zsh shell (or at least the version I am using, Oh-my-ZSH) has a feature that corrects you if you make small typos in command and file names:

$ pyhton scirpt.py
zsh: correct 'pyhton' to 'python' [nyae]? y
zsh: correct 'scirpt.py' to 'script.py' [nyae]? y
...

You can turn it on with the following line in your .zshrc:

# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
3
  • can it be made automatic? i know it is asking for trouble, mr fr- ./ -oe--rvoeorrpne-st --> zsh: automatically correcting to rm -rf / --no-preserve-root
    – cat
    Feb 13, 2018 at 0:12
  • 1
    @cat Not as far as I know. The reason you gave is one reason why but it would also prevent you from doing legitimate things like mv file1 file1.old, because it would correct the second filename to the first, making it a no-op.
    – Graipher
    Feb 13, 2018 at 5:59
  • 1
    tcsh does that too. Feb 13, 2018 at 23:49
11

You could try using the open dyslexic font in your terminal. It might help with reading the text. This is assuming that you're using the default ubuntu terminal, which I hope is the same as the GNOME terminal.

https://opendyslexic.org/

  1. Download it.
  2. Install the font.
  3. Open a terminal navigate to the menubar and select Edit->Profile Preferences
  4. Turn on custom font and select the open dyslexic mono font.
1
  • Installation can be done with sudo apt install fonts-opendyslexic. Feb 24, 2018 at 14:05
2

To complete @pomsky 's answer, I would like to add some points :

  • Learn how to automate things, especially learn how for loops work, how does read works, how does if works, what are [ ] and [[ ]], use the unofficial bash strict mode, because once a script is valid, it is easier not to make mistakes.

  • if you can, install the bash-completion package (can come with different names according to versions)

  • Use rm with the -i switch when in dangerous situations (like with sudo), or maybe install and use rmtrash (which will put garbage in trash)

  • Use cp with the -n switch, which will not overwrite existing files when copying. (Of course, more useful when copying recursively)

  • Learn how to use the ~/.bashrc file, it can make the $PS1 variable more clear for you.

And maybe the hardest if you are young :

  • Try to know a little better the state-of-the-art and common tools of what you are doing.

    • For instance, if you are a student learning how to develop with c++, try setting the $CXXFLAGS in your ~/.bashrc. (For instance : export CXXFLAGS=" -std=c++17 -fmax-errors=1 -Wall -Wextra -pedantic -Werror " according to your c++ version of course, so I guess c++11 for ubuntu), then compile with make main.cpp and your options will be carried over. Note that this set of option is pretty harsh : everything correct and standart will be seen as an error and prevent you from compiling.
2

Try "FISH" Friendly interactive shell. Available in the repos.

I used to struggle with command line using BASH. Fish remembers all last commands and offers completion. sudo apt install fish then in bash type; fish. If you like it look up instructions on how to make it your default shell. There are other shells available; FISH is my choice. Once you get started you might like it.

1
  • all shells I know remember the last used commands and tab completion
    – phuclv
    Apr 4, 2020 at 9:41
2

I learnt I was dyslexic after being a Unix engineer and a proficient shell user for many years on many different platforms (Linux, AIX and Solaris).

Dyslexia affects different people to different degrees so the assumption that "we see things out of order" can be an over simplification and frustrating if it doesn't affect you that way - I actually find the default fixed-width font of terminals extremely readable (white-on-black seems nice for me)

Shells are difficult to learn with lots of acronyms and unintuitive conventions to navigate, which often makes it hard to learn for people who enjoy straightforward words with regular patterns.

I now understand that most dyslexics learn and memorise from first-hand experience. We're very poor at rote learning or consuming a load of wordy theory. Once we've digested the theory by application, however, it usually sticks fast with a deep intrinsic understanding. To this end, Focus on finding shell examples and trying them out by typing them out by hand and understanding what each line does. Experiment, break things, stay up all night fixing it.

Over time you'll remember more and more commands and spot patterns in the way developers have implemented their programs which can be applied to the next command. However, not all commands follow the same conventions when passing arguments/parameters so it'll take a while to learn the commands that are similar.

Like anyone else, after a few years it'll become second nature. Over time, however, you may gain the dyslexic advantage where you intuitively know how to solve solutions and perform complex root-cause analysis using your 6th sense-like ability to spot patterns or breaks in patterns.

With the exception of the tab-completion and the up key advice, I find most answers will only make the experience even more overwhelming. Ignore them. Simplification is the key

2

There is a tool, which sits between a joke and a priceless helper.

https://github.com/nvbn/thefuck

You can try it in addition to other recommendations in this thread. The main idea is that when you f*** up writing something and receive the unknown command or whatever, this tool will correct and re-execute it.

It is not a silver bullet, but may be worth trying it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .