Creating Files and Directories
You want to organize your files by placing them in directories. But where do directories come from? For that matter, how do you create a file?
Use mkdir and touch.
mkdir creates directories. Mind your filepaths! This comand creates a new subdirectory in the current directory:
$ mkdir photos
This creates a new top-level directory. Only the superuser can do this:
# mkdir /local_bins
You can set permissions when you create a directory:
# mkdir -m 755 /shared
To create a subdirectory and all of its parent directories at once, use the -p flag:
$ mkdir -p photos/scanned/jpgs/thumbs
Most files are created by a program, such as a word processor, image editor, or compiler. You can also create a new, empty file with touch:
$ touch newfile.txt
You want to organize your files by placing them in directories. But where do directories come from? For that matter, how do you create a file?
Use mkdir and touch.
mkdir creates directories. Mind your filepaths! This comand creates a new subdirectory in the current directory:
$ mkdir photos
This creates a new top-level directory. Only the superuser can do this:
# mkdir /local_bins
You can set permissions when you create a directory:
# mkdir -m 755 /shared
To create a subdirectory and all of its parent directories at once, use the -p flag:
$ mkdir -p photos/scanned/jpgs/thumbs
Most files are created by a program, such as a word processor, image editor, or compiler. You can also create a new, empty file with touch:
$ touch newfile.txt
0 Comments