In this guide, we'll be talking a bit about the basic commands you should know to get around in a Unix or Linux environment. These will include the basics for navigating the filesystem, listing directories and editing basic text files. Additionally we'll go over the file structure found in your home directory and what it is used for.
Every unix system has a filesystem. It is built up out of directories and files that make up the operating system and all of the software that runs on it, as well as all the files and documents required to make things run. It's not important to know all the details of these files, but it is useful to know how to explore this filesystem.
Navigating the filesystem can be done using the “cd” command, cd standing for “change directory”. If you're not sure what directories you can go to, use “ls”: this will display a directory listing of the directory you are currently in. After logging in, this is usually your home directory.
Using cd is simple: all you have to do is “cd <directory-path>”. This may be an absolute path (starting with a slash, like /usr/bin) or a relative one (like ./my_subdirectory). If you wish to “go up” a directory, use “..” as the path. Alternatively, if you wish to return to your home directory, use “~” as the path.
With “ls” you can list the contents of a directory. However, this doesn't always display the whole directory. Files may be “hidden” in linux, by prefixing the name with a dot. To list such files, use ls with the “-a” option, like so: “ls -a”. You may also display extra information using the “-l” option. This will show things like file size and permissions.
Within the filesystem live the home directories for every user on the system. These can be found in “/home”. Your home directory can be found here as well. When logging in with SSH, you'll be placed inside your home directory by default. On Subcon Town, you'll have a number of contents already in your home directory:
Exploring the filesystem is one thing. Now that you know a bit about your own home directory, let's see about actually creating and managing files and directories for yourself. Below we'll explain a couple of important commands that will let you create, modify and delete files and directories. This will also include how to work with text files.
“touch” is a command that you can use to create a new empty file. Note that it only creates the file if it doesn't already exist. All you have to do is “touch <filename>”.
“mkdir” is a similar command, that allows you to create a new empty directory. Its usage is similar to the “touch” command: “mkdir <directory name>”
“mv”, short for “move”, is used to move files and directories around. It is also used to “rename” them (by moving them from one filename to another). Use the command like this: “mv <path_to_file> <path_to_where_the_file_should_go>”. To move whole directories around, you must use the “-r” flag like this: “mv -r <path_to_directory> <path_to_where_the_directory_should_go>”.
“cp”, short for “copy”, is used to copy files and directories around. Its use is very similar to the “mv” command above, but in this case the file gets duplicated instead of moved. Use the command like this: “cp <path_to_file> <path_to_where_the_copy_should_go>”. Similar to the “mv” command, to copy directories you must again use the “-r” flag.
“rm”, short for “remove”, is used to delete unwanted files and directories. Keep in mind this is permanent. Once removed, the file or directory is gone forever. Use the rm command like this: “rm <path_to_file>”. To delete a directory, use the “-r” flag: “rm -r <path_to_directory>”.
— to be completed later —