If you're a Linux user, the Terminal is probably the most powerful tool you would ever have. But the thing about the Terminal is that you need to learn how to use it if you want to benefit from it.
For the last few months, I've been playing with the Terminal a lot, and I came up with a long list of useful commands that I use regularly. Please let me know if I missed something important so I can add it to future posts.
π‘ If you found this content valuable, you can follow me on Twitter and Instagram.
TL;DR
-
Basic commands
- Zoom in β
[CTRL] + [+]
- Zoom out β
[CTRL] + [-]
- Print working directory β
pwd
- Clear the terminal β
[CTRL] + [l]
orclear
- Assign an alias β
alias [alias-name]="[command-to-run]"
- Source a file β
source [name-of-the-file-to-read-and-execute]
- Zoom in β
-
Change directory command (cd)
- Move to a specific directory β
cd [name-of-your-directory]
- Move to the parent directory β
cd ..
- Move to the home directory β
cd
orcd ~
- Move to the last directory yo were in β
cd -
- Move to a specific directory β
-
List command (ls)
- List all visible files and directories β
ls
- List all files and directories (include hidden files) β
ls -a
- Long Listed Format β
ls -l
- Human Readable Format β
ls -lh
- Combining arguments: Human Readable Format + Hidden files β
ls -lah
- Learn more about the ls command β
man ls
- List all visible files and directories β
-
Search
- Locate the binary for a program β
which [name-of-the-program]
- Locate the binary, source and user manual for a program β
whereis [name-of-the-program]
- Locate files and directories by name β
find [path-to-search] -iname [name-of-the-file-you-want-to-search]
- Learn more about the find command β
man find
- Learn more about the find command β
- Get a brief description for a command β
whatis [command-name]
- Locate the binary for a program β
-
History
- Get previous commands (one by one) β Use the
Up Arrow key
β¬οΈ to navigate your history - Get previous commands (full list) β
history
. - Repeat commands from history (bang command) β
history
β![number-of-the-command-to-repeat]
- Repeat last command (bang-bang command) β
!!
- Get previous commands (one by one) β Use the
-
Working with files and directories
- Create a new file (without open it) β
touch [name-of-your-file]
- Create a new file using a text editor β
vim [name-of-your-file]
ornano [name-of-your-file]
- Copy a file β
cp [source-path-of-your-file] [destination-path-for-your-file]
- Create a new directory β
mkdir [new-directory-name]
- Remove an empty directory β
rmdir [name-of-the-directory-you-want-to-remove]
-
Remove command (rm)
- Remove a file β
rm [name-of-your-file]
- Remove a directory recursively (use with caution) β
rm -rf [name-of-your-directory]
- Remove a file β
-
Concatenate command (cat)
- View a single file β
cat [name-of-your-file]
- View a single file including the line numbers β
cat -n [name-of-your-file]
- Copy the content of one file to another file β
cat [filename-whose-contents-is-to-be-copied] > [destination-filename]
- Learn more about the cat command β
man cat
- View a single file β
-
Move command (mv)
- Move a file β
mv [source-path-of-your-file] [destination-path-for-your-file]
- Rename a file β
mv [name-of-your-file] [new name-of-your-file]
- Move a file β
- Create a new file (without open it) β
Basic commands
Zoom in
Type [CTRL] + [+]
Zoom out
Type [CTRL] + [-]
pwd: Print Working Directory command
It prints the working directory path, starting from the root directory.
mauro_codes@DESKTOP-HIQ7662:~$ pwd
/home/mauro_codes
mauro_codes@DESKTOP-HIQ7662:~/projects$ pwd
/home/mauro_codes/projects
Clear command
Type clear
or [CTRL] + [l]
to clear the entire terminal screen and get a clean terminal to keep working.
Alias command
If you usually run a long command regularly and want to save time, you can assign a shorter alias for that command. Type alias [alias-name]="[command-to-run]"
to assign a new alias:
## Running the ls command
mauro_codes@DESKTOP-HIQ7662:~$ ls
projects
## Assign an alias, so we don't need to add the arguments every time we need to list something
mauro_codes@DESKTOP-HIQ7662:~$ alias ls="ls -lah"
## Running ls again (we get the result of `ls -lah`)
mauro_codes@DESKTOP-HIQ7662:~$ ls
total 16K
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 17:41 .
drwxr-xr-x 1 root root 512 Jan 22 10:38 ..
-rw------- 1 mauro_codes mauro_codes 3.0K Jan 22 23:58 .bash_history
-rw-r--r-- 1 mauro_codes mauro_codes 220 Jan 22 10:38 .bash_logout
-rw-r--r-- 1 mauro_codes mauro_codes 3.7K Jan 22 17:32 .bashrc
-rw-r--r-- 1 mauro_codes mauro_codes 807 Jan 22 10:38 .profile
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 projects
Note that this alias won't be persisted for future uses. If you want to persist your aliases, add them at the end of your .bashrc file located in your home directory.
Source a file
You can use the source
command to read and execute the content of a file line by line. Type source [name-of-the-file-to-read-and-execute]
:
## Print the content of the script.txt file (contains two commands)
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ cat script.txt
echo "hello world" ## Print a hello message
cal ## Print a calendar
## Source the script.txt to run each command inside
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ source script.txt
hello world
January 2021
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Change Directory command (cd)
Move to a specific directory
Type cd [name-of-your-directory]
:
## Check current directory
mauro_codes@DESKTOP-HIQ7662:~$ pwd
/home/mauro_codes
## Change directory
mauro_codes@DESKTOP-HIQ7662:~$ cd projects/
## Check new working directory
mauro_codes@DESKTOP-HIQ7662:~/projects$ pwd
/home/mauro_codes/projects
Move to the parent directory
Type cd ..
:
## Check current directory
mauro_codes@DESKTOP-HIQ7662:~/projects$ pwd
/home/mauro_codes/projects
## Move to the parent directory
mauro_codes@DESKTOP-HIQ7662:~/projects$ cd ..
## Check new working directory
mauro_codes@DESKTOP-HIQ7662:~$ pwd
/home/mauro_codes
Move to the home directory
Type cd ~
or just cd
as an alternative
## Check current directory
mauro_codes@DESKTOP-HIQ7662:~/projects/awesome-app$ pwd
/home/mauro_codes/projects/awesome-app
## Move to the home directory
mauro_codes@DESKTOP-HIQ7662:~/projects/awesome-app$ cd ~
## Check new working directory
mauro_codes@DESKTOP-HIQ7662:~$ pwd
/home/mauro_codes
Move to the last directory you were in
Type cd -
to navigate to the previous directory you were in
## Check the current directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ pwd
/home/mauro_codes/projects/landing-page
## Move to another directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ cd /home/mauro_codes/
## Check the new directory
mauro_codes@DESKTOP-HIQ7662:~$ pwd
/home/mauro_codes
## Go back to the previus directory you were in
mauro_codes@DESKTOP-HIQ7662:~$ cd -
/home/mauro_codes/projects/landing-page
List command (ls)
Lists the content of the directory you're currently in.
List all visible files and directories
Type ls
without any additional argument to get all the files and directories (this command will exclude hidden files like the dotfiles).
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects$ pwd
/home/mauro_codes/projects
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects$ ls
awesome-app landing-page nextjs-tailwindcss-blog-starter personal-blog
List all files and directories
Type ls -a
to get all the files and directories (including the hidden files)
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects$ pwd
/home/mauro_codes/projects
## List the content for the working directory (including hidden files)
mauro_codes@DESKTOP-HIQ7662:~/projects$ ls -a
. .. .config .configu awesome-app landing-page nextjs-tailwindcss-blog-starter personal-blog
Long Listed Format
Type ls -l
to get all the visible files and directories including additional metadata like permissions, owner, size and modified date and time.
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/nextjs-tailwindcss-blog-starter$ pwd
/home/mauro_codes/projects/nextjs-tailwindcss-blog-starter
## List the content for the working directory (using the long listed format)
mauro_codes@DESKTOP-HIQ7662:~/projects/nextjs-tailwindcss-blog-starter$ ls -l
total 140
-rw-r--r-- 1 mauro_codes mauro_codes 4487 Jan 22 12:55 README.md
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 components
-rw-r--r-- 1 mauro_codes mauro_codes 1068 Jan 22 12:55 config.ts
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 helpers
Human Readable Format
Type ls -lh
to get all the visible files and directories in long-listed format, but with a Human Readable Format (User-friendly file size).
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/nextjs-tailwindcss-blog-starter$ pwd
/home/mauro_codes/projects/nextjs-tailwindcss-blog-starter
## List the content for the working directory (using the long listed format + human readable format)
mauro_codes@DESKTOP-HIQ7662:~/projects/nextjs-tailwindcss-blog-starter$ ls -lh
total 140K
-rw-r--r-- 1 mauro_codes mauro_codes 4.4K Jan 22 12:55 README.md
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 components
-rw-r--r-- 1 mauro_codes mauro_codes 1.1K Jan 22 12:55 config.ts
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 helpers
Combining arguments
Type ls -lah
to get all the files and directories (including hidden files) in Human Readable Format.
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/nextjs-tailwindcss-blog-starter$ pwd
/home/mauro_codes/projects/nextjs-tailwindcss-blog-starter
## List the content for the working directory (include hidden files + human readable format)
mauro_codes@DESKTOP-HIQ7662:~/projects/nextjs-tailwindcss-blog-starter$ ls -lah
total 140K
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 13:08 .
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 ..
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 .git
-rw-r--r-- 1 mauro_codes mauro_codes 362 Jan 22 12:55 .gitignore
-rw-r--r-- 1 mauro_codes mauro_codes 4.4K Jan 22 12:55 README.md
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 components
-rw-r--r-- 1 mauro_codes mauro_codes 1.1K Jan 22 12:55 config.ts
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 22 12:55 helpers
Learn more about the ls
command
There are dozens of arguments that you can use with the ls
command. If you want to dig dipper,
type man ls
in your terminal to display the user manual for the ls
command.
Search
Locate the binary for a program
If you want to locate where the binary (executable) for a specific command or program is located. You can use the which
command:
## Locate binary for the ls command
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ which ls
/usr/bin/ls
## Locate binary for git
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ which git
/usr/bin/git
Locate the binary, source, and user manual for a program
You can use the whereis
command to locate the binary, source, and user manual for a program. You can use the -b
, -m
, and -s
arguments to limit the results to binaries, manual and source, respectively
## Locate binary, manual, and source for git
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ whereis git
git: /usr/bin/git /mnt/c/Program Files/Git/cmd/git.exe /usr/share/man/man1/git.1.gz
## Locate only binary and manual for Git, and only the manual for ls command
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ whereis -bm git -m ls
git: /usr/bin/git /mnt/c/Program Files/Git/cmd/git.exe /usr/share/man/man1/git.1.gz
ls: /usr/share/man/man1/ls.1.gz
Locate files and directories by name
Type find [path-to-search] -iname [name-of-the-file-you-want-to-search]
to find any file or directory that contain the given name in their title.
- The path to search is optional. If it is not specified, the
find
command will run on your current working directory (and its descendants) - The
-iname
argument means that our search will be case insensitive.
- If you want to learn more about this command, type `man find` to display the user manual.
## Check current working directory
mauro_codes@DESKTOP-HIQ7662:~/projects$ pwd
/home/mauro_codes/projects
## Find files that contain "posts" on my current working directory and its descendants
mauro_codes@DESKTOP-HIQ7662:~/projects$ find -iname posts
./nextjs-tailwindcss-blog-starter/pages/posts
./nextjs-tailwindcss-blog-starter/posts
## Find files that contain "posts" on a specific directory and its descendants
mauro_codes@DESKTOP-HIQ7662:~/projects$ find ./nextjs-tailwindcss-blog-starter/pages/ -iname posts
./nextjs-tailwindcss-blog-starter/pages/posts
Get a brief description for a command
If you don't know what a certain command does, Type whatis [command-name]
like this:
## Asking about the cat command
mauro_codes@DESKTOP-HIQ7662:~/projects$ whatis cat
cat (1) - concatenate files and print on the standard output
## Asking about the find command
mauro_codes@DESKTOP-HIQ7662:~/projects$ whatis find
find (1) - search for files in a directory hierarchy
History
Get previous commands (one by one)
You can access your recent command by pressing the Up Arrow key
β¬οΈ. This is very useful if you want to repeat your last command. Let's say we move to a specific directory, and then we check our working directory like this:
## Move to a specific directory
mauro_codes@DESKTOP-HIQ7662:~$ cd projects/awesome-app/
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/awesome-app$ pwd
/home/mauro_codes/projects/awesome-app
β¬οΈ We'll get the pwd
command
β¬οΈβ¬οΈ We'll get the cd projects/awesome-app
command
Repeat previous commands (full list)
Type history
to get a numerated list containing the previous commands you run. Then, type ![number-of-the-command-to-repeat]
to repeat that command
## Get the history list
mauro_codes@DESKTOP-HIQ7662:~$ history
1 ls
2 clear
3 pwd
4 mkdir projects
5 cd projects
## Run command number 1 (ls)
mauro_codes@DESKTOP-HIQ7662:~$ !1
projects
Repeat the last command
Type !!
(bang-bang command) to repeat the last command. This is especially useful when you forgot to add sudo
on your last command:
## Running update without sudo (Permission denied)
mauro_codes@DESKTOP-HIQ7662:~$ apt update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
## Using the bang-bang command to append the last command after sudo
mauro_codes@DESKTOP-HIQ7662:~$ sudo !!
sudo apt update
[sudo] password for mauro_codes:
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
...
Working with files and directories
Create a new file (without open it)
Type touch [name-of-your-file]
to create a new file without open it on a text editor. This is useful if you just want to create an empty file but don't need to change it right now.
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ pwd
/home/mauro_codes/projects/landing-page
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md
## Create an empty js file
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ touch main.js
## List the content for the working directory (including your new file)
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md main.js
Create a new file using a text editor
Type nano [name-of-your-file]
to create a new file and open it using the text editor nano. If you want to learn more about nano, you can Type man nano
on your terminal to display the nano user manual.
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ pwd
/home/mauro_codes/projects/landing-page
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md main.js
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ nano index.html
After running the last command, you'll be able to edit the file using nano:
Copy a file
You can use the cp
(Copy) command to copy files and directories
Type cp [source-path-of-your-file] [destination-path-for-your-file]
to copy a file into a new destination.
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md index.html main.js temp
## Copy the README.md file into the temp directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ cp README.md temp/README.md
## List the content for the working directory and check that your file is still there.
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md index.html main.js temp
## List the temp directory's content and check if your file was copied.
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls temp/
README.md index-copy.html
Create a new directory
Type mkdir [new-directory-name]
to create a new directory in your current working directory
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md index-empty-copy.html index.html main.js
## Create a new directory called "scripts"
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ mkdir scripts
## List the content to check if our new directory was created
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md index-empty-copy.html index.html main.js scripts
Remove an empty directory
Type rmdir [name-of-the-directory-you-want-to-remove]
to remove an empty directory. Please note that this command will only work with empty directories.
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md index.html main.js temp
## Remove the "temp" empty directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ rmdir temp
## List the content and check that the directory was removed
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md index.html main.js
Remove command (rm)
Remove a file
Type rm [name-of-your-file]
to remove a file
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page/temp$ ls
README.md index-copy.html
## Remove the index-copy.html file
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page/temp$ rm index-copy.html
## List the content for the working directory and check that the file was removed
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page/temp$ ls
README.md
Remove a directory recursively
Type rm -rfi [name-of-your-directory]
to recursively remove a directory with all its files and sub-directories.
Please be careful! This is one of the most dangerous commands you can run. If you run
rm -rfi /
, you'll erase your entire root partition. Be sure to specify the path for the directory you want to delete. In this example, In this example, I include the-i
argument to ask for confirmation.
## List the content of the temp folder (It has one file)
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls temp/
total 0
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 24 19:45 .
drwxr-xr-x 1 mauro_codes mauro_codes 512 Jan 24 19:44 ..
-rw-r--r-- 1 mauro_codes mauro_codes 8 Jan 24 19:45 file.txt
## Recursively remove the temp folder
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ rm -rf temp/
## Check that the temp folder was removed
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls temp/
ls: cannot access 'temp/': No such file or directory
Concatenate command (cat)
You can use the cat
(concatenate) command to read data from a file and print their content as output
View a single file
Type cat [name-of-your-file]
:
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ pwd
/home/mauro_codes/projects/landing-page
## Print the content of the index.html file
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ cat index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>My Website</title>
</head>
<body>
<script src="js/main.js"></script>
</body>
</html>
View a single file including the line numbers
Type cat -n [name-of-your-file]
:
## Check the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ pwd
/home/mauro_codes/projects/landing-page
## Print the content of the index.html file
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ cat -n index.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8" />
5 <meta http-equiv="x-ua-compatible" content="ie=edge" />
6 <meta name="viewport" content="width=device-width, initial-scale=1" />
7
8 <title>My Website</title>
9 </head>
10
11 <body>
12 <script src="js/main.js"></script>
13 </body>
14 </html>
Copy the content of one file to another file
Type cat [filename-whose-contents-is-to-be-copied] > [destination-filename]
:
## Create an empty file called index-empty-copy.html
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ touch index-empty-copy.html
## Copy the content of index.html to index-empty-copy.html
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ cat index.html > index-empty-copy.html
## Print the content of the index-empty-copy.html file
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ cat index-empty-copy.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>My Website</title>
</head>
<body>
<script src="js/main.js"></script>
</body>
</html>
Learn more about the cat
command
Type man cat
to display the user manual for the cat
command
Move command (mv)
You can use the mv
(move) command for moving and renaming files
Move a file
Type mv [source-path-of-your-file] [destination-path-for-your-file]
to move a file into a new directory
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md index-empty-copy.html index.html main.js temp
## Move the index-empty-copy.html file to the temp directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ mv index-empty-copy.html temp/index-empty-copy.html
## List the content again and check that the file is no longer in the current working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls
README.md index.html main.js temp
## List the temp folder and check that the file is now there.
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page$ ls temp/
index-empty-copy.html
Rename a file
Type mv [name-of-your-file] [new name-of-your-file]
to rename a file
## List the content for the working directory
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page/temp$ ls
index-empty-copy.html
## Rename the index-empty-copy.html file
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page/temp$ mv index-empty-copy.html index-copy.html
## List the content for the working directory (check if your file's name was updated)
mauro_codes@DESKTOP-HIQ7662:~/projects/landing-page/temp$ ls
index-copy.html
Final words
I missed tons of powerful commands on this post, but I decided to keep them for a future post. This is already huge.π
Top comments (42)
Good overview!
For people who are used to using nano, I recently came across this editor: micro
It's in a similar vein as nano, in terms of simplicity, but with modern features like mouse-support, integrated terminal-emulator (and fitting splits).
I can only recommend you try it :D
I was afraid of using vim and instead used nano for almost 3 years. Changing to vim changed my workflow A LOT! I'd really suggest that new comers try to familiarize with vim. You don't have to be power user just Insert & save & quit commands would do fine. When you feel comfortable enough with terminal just switch to vim completely. If you are sshing into servers a lot It'll really make a difference.
You're talking with a big vim nerd here! πI plan to write about that in the future because it is insanely powerful, and, as you said, you just need to know the basics to use it as a regular text editor.
But I wanted to keep this post centered around the terminal.
Haha! My reply wasn't to you actually it was against Robert's "micro" suggestion, very good post keep up the good work! I'd really like to see an advanced Vim post here btw. :D
I'm still afraid of using vim xD
Not knowing the quit-command in vim, is a beginners nightmare that can scar you. Someday I'll might look into vim aswell, I hear a lot of good things about it :D
Iβve been there! Once you learn the basics, itβs addictive to keep learning. But there is a lot of hate/love around Vim. Is not for everyone.
Thanks for your comments, Robert! I didn't hear about micro, but it looks amazing!! I will definitely try it!
Try also Ctrl + R and type part of the used command. Insteat of the history command.
I was here to write the same comment. Reverse searching is awesome!
I didnβt know about that one! Thanks for sharing, Konstantin!
Useful shortcuts i like:
ctrl + p: Replace [up], last command
ctrl + a: Replace [Home], go to beginning of the line
ctrl + e: Replace [End], go to end of the line
ctrl + f: forward one char
ctrl + b: backward one char
ctrl + w: Deletes one word
esc + f: forward one word
esc + b: backward one word
Useful to who uses keyboard without arrows or just dont wanna move hands.
Thanks for your feedback, Samuel. I didn't know about those shortcuts. They are messing with my head because I'm used to hitting "ctrl + w" and "ctrl + b" to move backward and forward in vim π
Don't forget
ctrl - r : Search history for command
My newest favourite History command uses grep and is great for finding a command that you have a faint memory of.
history | grep "keyword"
just use ctrl - r
Does the same thing. :)
True! I included the ctrl + r shortcut in my second post about the Linux terminal (which will be published next Monday)
I love that approach! Btw, the grep command is one of the many that I decided to add in another post because this one was already too big π
Great stuff, look forward to reading your next mammoth post π
For most situations, I would prefer searching through the history with
CTRL+r
(you might consider adding that one), but yes sometimes you want to see the full list.OK, that's pretty awesome! Thanks for that.
I didn't know about
whereis
. Highly useful. Thanks for sharing!Glad to hear that it was useful! I'm working on the second part of this post so stay tuned!
Looking forward to it :)
Good job, thanks for the time invested.
You're welcome Jhonathan! I'm planning to release a second part with more commands! Stay tuned
Im waiting for that
Ehm,
DESKTOP-HIQ7662
? That's Windows terminal and Linux shell...You got me! π I was working on Windows with the Ubuntu Terminal while writing this post. Shame on me π
Hi, can I include this cheat sheet in my cheat sheet compilation?
The ultimate Cheat sheets compilation (200+) - π₯π / Roadmap to dev π
DevLorenzo γ» Mar 2 γ» 17 min read
Thanks
Yep of course
Ultra useful, thanks Mauro!
Awesome post ππ
Thanks!
Some comments may only be visible to logged-in visitors. Sign in to view all comments.