DEV Community

Cover image for Terminal , Shell, CLI : Your first 20 commands;
Ebenezer Enietan (Niza)
Ebenezer Enietan (Niza)

Posted on • Updated on

Terminal , Shell, CLI : Your first 20 commands;

A terminal is a program that runs a shell and allows us to enter commands. Examples of terminal emulators include: Command prompt, guake, gnome-terminal, terminator etc. Any wrapper program that runs a shell interpreter is a terminal.

The shell is a command-line interpreter. The shell is the program that actually processes commands and outputs results some examples of shells are: Bash, fish, zsh, ksh, sh, tsch, Power Shell, pwsh cmd, yori, 4dos, command.com.

A command-line interface(CLI) is any type of interface that is used to enter (textual) commands. One of these is the terminal, but some programs have their own command-line interfaces.

We connect with computers in a variety of ways, including utilizing a keyboard and mouse, touchscreen interfaces, and speech recognition systems. A graphical user interface is a most often utilized method of interacting with personal computers (GUI). We deliver instructions with a GUI by clicking a mouse and using menu-driven interactions. This way of delivering instructions to a computer in certain cases and for certain repetitive performs poorly, so we can take advantage of the Unix shell. The Unix shell is both a command-line interface (CLI) and a scripting language that can execute repetitive tasks automatically and quickly with the proper commands.

Here are a some commands and what they do; options are in parenthesis

1. $ whoami

It returns your username.

2. $ ls

list the contents of the current directory(ls –F, ls -help, man ls)

3. $ pwd
present working directory

4. $ cd
Change direct eg cd Desktop moves user to desktop directory

5. $ mkdir
mkdir [path] creates a new directory.
Eg. mkdir web

6. $ nano
A text editor eg to make a text list.txt use the command nano list.txt Depending on the type of work you do, you may need a more powerful text editor than Nano.

7. $touch
Used to create files touch list2.txt

8. $ rm
rm [path] removes (deletes) a file.
Eg. rm list2.txt (rm -r remove directory and all it contents)
The shell does not have a trash bin: once something is deleted, it’s really gone.

9. $ mv
mv [old] [new] moves or renames a file or directory.
Eg. mv list.txt buy.txt

10. $ cp
Copy file cp [old] [new] copies a file.
eg cp list.txt fish.txt

11. Wild cards

  • matches zero or more characters in a filename, so *.txt matches all files ending in .txt. Eg ls *.txt

? matches any single character in a filename, so ?.txt matches a.txt but not any.txt.
Eg ls list?.txt

12. $ wc
Word counts command: it counts the number of lines, words, and characters in files

eg wc list.txt

13. $ cat
it prints the contents of files one after another.
eg cat list.txt

14. $ sort

command to sort the contents of a file (sort -n for numbers)
Eg sort lists

15. $ echo
The echo command prints text
Eg echo hello

16. $ echo hello > list.txt
command > [file] redirects a command’s output to a file (overwriting any existing content).

17. $ echo hello >> list.txt
command >> [file] appends a command’s output to a file.

18. $ head
head displays the first 10 lines of its input.
Eg head -n 3 animals.csv > animals-subset.csv

19. $ tail
displays the last 10 lines of its input.
Eg tail -n 3 animals.csv > animals-subset.csv

20. $ [first] | [second]
pipeline: the output of the first command is used as the input to the second.

where can i learn more about shell?

learn more about shell

Top comments (2)

Collapse
 
nnekajenny profile image
Jennifer Eze

Woo, Awesome

Collapse
 
emmykolic profile image
Emmanuel C. Okolie

My God. This is awesome 👌 I've gone through it, and saw alot of things I don't know. Thank you sir ☺ this is a top notch 👏