I found the Linux command line quite intimidating when I first started learning to code. It seemed to require extensive and comprehensive knowledge and understanding of commands and keyboard shortcuts. However, as I read more about it and practiced what I learned, I realized that it isn't as scary as it seemed; that It only requires a lot of constant practice. I also discovered that others , which made me realize that I wasn't alone. feel the same way The other thing I discovered during this period is that we are all beginners and sharing is helpful, since no one is an island. So I decided to with others starting out as well. As we all know, learning is never-ending. There will always be new tools and new commands to learn, especially when you're a beginner. The following tips have helped me navigate through files and directories on the command line. ๐ share my experience Manipulating Files and Directories To print a string of characters to your screen, use the command by typing ๐ e.g. . To print without a newline being inserted, use the option as follows; type ๐ . To print a string of characters to a file without using a text editor, use the . ๐ e.g. . echo echo <string> echo Hello world -n echo -n <string> redirect operator > echo "string" > filename echo "this prints to file" > index.html To add a new string of characters to the next line of the same file, use the . ๐ . To dump the contents of a file to your screen, use the command: ๐ e.g . To facilitate the comparison of files that are similar but not identical, use the command: ๐ . append operator >> echo "string" >> filename cat cat <filename> cat book.txt diff diff <filename1><filename2> Note that when there is no difference between two files, simply outputs nothing. To dump the contents of a file (or to combine the contents of multiple files) into a separate one, direct the output of the command to the new file using the redirect operator: diff cat > ๐ . cat filename(s) > newfile To abort the current task and regain user-control of the terminal, press ๐ . If this command fails, hit the key. To be able to move quickly within the command line, press ๐ to get to the beginning of the line; to get to the end of the line and; to clear the entire line and start over. Ctrl-C Esc Ctrl-A Ctrl-E Ctrl-U To learn more about a command: ๐ e.g . man <command name> man cat Note that pages use the same interface as the command so you can navigate through both using the same key shortcuts. To open a new terminal tab (or window): ๐ and respectively. To clear your screen: ๐ or . To exit a terminal window (or tab): ๐ or or type ๐ . man less Ctrl+Shift+T Ctrl+Shift+N clear Ctrl-L Ctrl-D Ctrl+Shift+W exit To run the previous command exactly as written, use the exclamation point (pronounced bang) and type . Another way to repeat previous commands is by typing followed by a character (or a number of characters), which runs the last command that started with those characters. For example, to run the last command issued, type ๐ . Another powerful technique is to enter ๐ . This allows you to search interactively through your previous commands, and then optionally edit the result before executing. ! !! ! ls ! l Ctrl+R To create a hard link to a file; use the command by first typing the name of the file you want to link to (i.e the source file), followed by the name of the linked file you want to create (i.e the target) for example ๐ . To force a link (or to execute a command without having to confirm it) use the flag . ln ln letter.doc book.doc (say, to an existing file) -f ln -f letter.doc index.html The default type of link that gets created when using the command is the hard link. Hard links create an identical copy of the linked file on disk, that gets updated automatically as the source file is updated. However, this type of link does not work for directories. ln To create a link to a directory, use the flag to create a symbolic link. This flag can also be used for linking to files as well, not just directories for example: . Symbolic links can also link to files or directories on other file systems. . -s ln -s letter.doc index.html File systems refer to directories and files Inspecting Files and Directories To open a file or a directory or access a URL, type ๐ . To download a file from the internet, use the utility which allows you to interact with URLs on the command line; ๐ . To fetch the HTTP header of a site, type ๐ . xdg-open <filename>/<directory>/<URL> curl curl -OL <URL> curl -I <URL> To view the beginning and end of a file, use the and commands by typing head tail ๐ and respectively. They show the first and last 10 lines of the file, as applicable. To print the first lines of a file (instead of the first 10): head <filename> tail <filename> n ๐ . head -n <number> <filename> To count the number of lines in a file, type ๐ . The output shows three separate figures, indicating the number of lines, words, and bytes in the file. To view a file that is actively changing, type ๐ . This command is mostly executed when monitoring files used to log the activity of web servers for instance, in a practice known as 'tailing the log file'. wc <filename> tail -f <filename> To easily navigate through the contents of a large file, use ๐ the command for example type ๐ . While in mode; press the or to move forward a page; the to move one line up or down; to move a page up; press ๐ and to move to the beginning and end of the file respectively (to go directly to a specific line, type ๐ ); to search through the file for a string/word, use the forward slash key , e.g. type ๐ ; press ๐ to move to the next search result and to the previous search result and to quit the command, press ๐ . less less <filename> less spacebar Ctrl+F arrow keys Ctrl+B 1G G <linenumber>G / /<word> n N less q To search directly for a word/string in a file, use the command: ๐ . To search for a word/string in a file when you aren't sure where the file is, use the flag: ๐ . To perform a case-insensitive search using use the flag by typing ๐ . grep grep <word> <filename> -r grep -r <word> grep -i grep -i <word> <filename> To exclude a word/string from a search term when using , use the option as follows ๐ . To find the line number(s) in a file where a word appears: ๐ . To print the first 'n' lines of a search result, pipe to the command as follows ๐ . grep -v grep <search term> <filename> | grep -v <word> grep -n <word> <filename> head grep -i <word> <filename> | head <-n> To count the number of lines containing references to a search term/string, use the pipe and word count commands as follows ๐ . To print the history of commands you have previously executed in your terminal shell, use the command and pipe it to as follows ๐ . To execute a specific command in your command history, type ๐ where represents the command number e.g. the 43rd command in your history. | wc grep <word> <filename> | wc history | less history | less !n n Lastly, use the command to modify system files or directories and execute tasks as . sudo root ๐ ๐ As always, thanks for reading! First Published here