Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1
#   file:   coffeecup.conf
# owner: matthew
# group: yirgacheffe
user::rw-
group::rw-
other::r--
group:qa:rwx
group:uat:rwx
mask::rwx

Working with Files


Managing files in your home directory involves using one or more easily
remembered commands.


Creating a File with touch


If you are the user matthew, to create an empty file called myfile within
your current directory, use the following command:


Click here to view code image
matthew@seymour:~$ touch myfile


To edit this file, you must use a text editor. (Several text editors are discussed
in Chapter 14, “Automating Tasks and Shell Scripting.”) However, it is
sometimes useful to create an empty file as doing so also creates an access
record because of the time and date information that is connected to the file.
You can also use touch to update this information, called a timestamp,
without otherwise accessing or modifying a file.


You can create a file in a different location by changing what is after touch.
To create a new file in /home/matthew/randomdirectory, if you are
already in your home directory, you can use the following:


Click here to view code image
matthew@seymour:~$ touch randomdirectory/newfile


Or from anywhere using an absolute path, you can use this:


Click here to view code image
matthew@seymour:~$ touch /home/matthew/randomdirectory/newfile


Or from anywhere using a path shortcut, you can use the following command:


Click here to view code image
matthew@seymour:~$ touch ~/randomdirectory/newfile

Free download pdf