Hands-On System Programming with Go
上QQ阅读APP看书,第一时间看更新

Navigation and interaction

While using a shell, one of the directories will be the working directory, when paths are relative (for example, file.sh or dir/subdir/file.txt). The working directory is used as a prefix to obtain an absolute one. This is usually shown in the prompt of the command line, but it can be printed with the pwd command (print working directory).

The cd (change directory) command can be used to change the current working directory. To create a new directory, there's the mkdir (make directory) command.

To show the list of files for a directory, there's the ls command, which accepts a series of options, including more information (-l), showing hidden files and directories (-a), and sorting by time (-t) and size (-S).

There is a series of other commands that can be used to interact with files: the touch command creates a new empty file with the given name, and to edit its content you can use a series of editors, including vi and nano, while cat, moreand less are some of the commands that make it possible to read them.