BEGINNERS GUIDE TO THE COMMAND LINE (DEBIAN/UBUNTU/RASPBIAN)
--

This guide will teach you the basics of the command line. It's aimed at beginners, and covers enough to get you up and running.

It's specifically for Debian based distros, like Ubuntu, Elementary, Raspbian etc. Most of the commands will work on other, non-debian systems, but some will be a bit different, so do your research.

If you want to test out the commands without worrying about messing your system up, the easiest way is to grab a Raspberry Pi and load up Raspbian.

(Watch the video for all the commands)

- Youtube link
- Archive.org mirror
- Torrent
- Keybase mirror

FILE SYSTEM & STRUCTURE

Paths tell the terminal where to look for specific files and directories, so it's important to learn about how your system structures it's files so they can be found easily. Note that in this video, the words folder and directory are interchangeable.

For Linux and other unix-like systems such as Mac OS X, the base directory which everything else is contained in is called root. It is represented by the first / in a path. In the example shown, the different sections of the path each represent a directory or file. You basically add more to the right side of the text path the deeper you want to go into nested directories.

If you're having trouble with this, you can easily drag a file or folder into your terminal app to get the correct path.

MANUAL PAGES

Manual pages contain all important information for the different command line programs on your system. They contain information about the programs, the various options, examples of how to use them and more. To access them, simply type “man” followed by a space, then the apps name.

This will be your first port of call if you want to troubleshoot or try some new options.

To exit, just press q.

SUPER USER

As a security precaution, normal users don't have permission to do some things on the system, since you could accidentally render your computer unusuable.

That's where the super user comes in. You may see the word sudo typed before other commands, and this basically gives you permission to do admin level tasks on your system. Depending on how your system is set up, you will be asked for the admin password.

There is also the root user, but that's a little outside the scope of this video.

VIEW CURRENT DIRECTORY

To know where you currently are in the system, use the pwd command then press enter. It'll show a path to the current directory you're in.

CHANGING DIRECTORY

Use the cd command to change directories. Type cd, a space, then the path to where you want to go, then press enter.

You can use the tilde (~) symbol as a shortcut for your home folder to save you time typing.

Another tip to change to a level above where you are is to use two periods.

MOVING FILES

You can move files using the mv command. Type in mv, the path to the file you want to move, then the path where you want to move it.

This can also be used for renaming files, you just simply change the input and output file names, and it will automatically rename it at the same time.

FINDING FILES

One of the simplest ways to find files is to use the aptly named find command.

If you know the filename, but not where it is, type the following, replacing what's between the quotes with the file name:

find -iname "file.txt"

This will search the current directory and any nested directories inside it, and spit out a path if a match is found.

If you want to find specific file types, you can use the wildcard symbol. For example if you want to find txt files:

find -iname "*.txt"

MAKING NEW DIRECTORIES

The mkdir command, as you probably guessed, makes directories. To make a new directory wherever you currently are in the system, type mkdir, then the name of the directory. Make sure there are no spaces, and remember it is case sensitive.

You can also create new directories in other places on your system, by including the full path before your new directory name, as shown in the example.

DELETING FILES/DIRECTORIES

To remove files, you can use the rm command. Type rm, followed by the file, or the full path to the file you want to delete.

If you want to delete a directory full of files, you can add the -rf options.

Also check out the shred command if you want to securely delete files too.

COPYING FILES

To copy files, use the cp command. Similar to the move command, you simply type cp, the path to the file you want to copy, then the path where you want to copy it to.

LISTING FILES/DIRECTORIES

Use the ls command, to list everything inside the present directory you're inside. Perfect for quickly showing what's there.

I also like to use the -1al options to list files in order, showing hidden files, as well as other size and ownership info.

FIND PROGRAMS

You can use the apropos command to find specific programs using a keyword. For example you may have installed a calculator app, but forgot the exact name of it. Just type apropos, a space, then the keyword, in this instance, calculator.

Press enter and you'll see the corresponding programs you have that fit the keyword.

INSTALLING NEW PROGRAMS

For those used to Windows or Mac, installing apps by command line might be a bit strange at first, but it's not so bad.

Use the sudo apt-get install command followed by the name of the program you want to install.

If it's in the repositories, it will be downloaded and installed.

sudo apt-get install programname

You can also install programs manually, but that is outside the scope of this video.

REMOVING PROGRAMS

To remove programs, use the same command for installing programs, but instead of the install option, use remove.

sudo apt-get remove programname

VIEW INSTALLED PROGRAMS

To view all the packages that are currently installed on your system, use the dpkg utility with the -l option. This will list everything you have installed.

dpkg -l

SEARCHING REPOSITORIES

If you're looking for an app, but don't know it's specific name, you can use this command. Replace the last word with a keyword of your choice, and all the repositories set up on your system will be searched. It's really helpful when you're looking for new apps to install.

sudo apt-cache search keyword

VIEWING CURRENT PROCESSES

To view all the processes currently running on your system, use the ps command. I like to use the -acx options.

This will tell you information such as the process name and number, which user initiated it, and how long it's been running.

KILLING PROCESSES

To kill a process, you'll need the process ID from the previous section for whatever app or process you want to stop. Once you have it, type kill, a space, then the process number. This will automatically kill the process, which is pretty handy if it's freezing or acting strangely.

KILLING COMMANDS

If you have a command line program running in the terminal and it's not responding, you can kill it by press ctrl + c

CLEARING THE SCREEN

If you find the screen is getting too cluttered, you can clean it up using the clear command. Alternatively, you could press ctrl + l

EXITING

When you've finished your terminal session, it's best to exit properly. Simply type exit and press enter.

CONCLUSION

It might be a little intimidating when you're first starting out, but getting familiar with the command line can really open up so many possibilities. This is just the tip of the iceberg, and there are literally millions of command line apps out there. You can start to run custom scripts, automate things, basically do anything. It's like unlocking a whole other side to your computer.

Anyways, I hope you found this useful

--
BY NODE