Search the terminal on your Operating system, but if you are using Windows, don't use the default Windows terminal. Check out the video on how to install a terminal emulator. For Mac users, you don't need installation, use the default terminal.
Common terminals to use are:
pwd(print working directory)
ls(list file and directory)
In a tree-like pattern of the directory (folder)
A directory may contain files and subdirectories
The first directory in the file system is called the root directory
One important difference between Windows and Unix-like OS like Linux is that Linux does not employ the concept of drive letters. While Windows drive letters split the file system into a series of different trees (one for each device), Linux always has a single tree.
The acronym PWD stands for Present Working Directory. It is commonly used in the context of command-line interfaces and operating systems to refer to the current directory in which a user is working. The
pwd command is often used to retrieve and display the full path of the current directory. That is the directory we are standing in is called the working directory. To see the name of the working directory, we use the
. notation refers to the working directory itself and the
.. notation refers to the working directory's parent directory.
If we type
cd followed by nothing,
cd will change the working directory to our home directory.
A relative shortcut is to type
File names that begin with a period character are hidden. This only means that
ls will not list them unless we say
- An example is
File names in Linux, like Unix, are case-sensitive. The file names File1 and file 1 refer to different files.
Linux has no concept of a file extension like the Windows system. You may name files any way you like. However, while Linux itself does not care about file extensions, many application programs do.
Though Linux supports long file names which may contain embedded spaces and punctuation, limit the punctuation characters to period, dash and underscore. Use underscores instead of spaces to represent spaces between words in a file name.
List the files in the working directory in long format.
ls -l /etc /bin
List the files in the
/bin directory and the
/etc directory in long format.
ls -la ..
ls -la /foldername
List all files (even the ones with names beginning with a period character, which are normally hidden) in the working directory's parent in a long format.
Most commands operate like this:
command -option arguments
A Closer Look at Long Format
For example, try
ls -la, you will get more information about the file.
If you run the command
ls -l you will get the output that looks like this:
total 4 -rw-r--r-- 1 TechstackMedia - Osagie 197610 3092 May 25 14:28 README.md
Let's break down the output:
total 4: This line represents the total number of 1KB blocks used by the files listed below it. In this case, the total size is 4KB.
-rw-r--r--: This section represents the file permissions. In this example, it indicates that the file is readable and writable by the owner (
rw-), readable by the group (
r--), and readable by others (
1: The number 1 represents the number of hard links to the file. In this case, there is only one hard link pointing to the file.
TechstackMedia: This is the owner of the file. In this case, the file is owned by the user
-: This hyphen represents the group associated with the file. In this case, the group is not explicitly specified.
Osagie: This represents the group associated with the file. In this example, the group is
197610: This indicates the file size in bytes. In this case, the file
README.mdis 3092 bytes.
May 25 14:28: This represents the file's last modification date and time.
README.md: This is the name of the file.
touch command is a versatile and powerful tool that allows you to create and modify files with ease in various operating systems, including Linux, macOS, and Unix. Its simplicity and efficiency make it a fundamental command for managing files and timestamps.
One of the primary functions of the touch command is to create a new file. Using the command is as simple as typing touch followed by the desired filename. For example, to create a file called example.txt, you would execute the following command:
You can also specify the timestamp. In the example below a file named custom.txt with a specific timestamp of December 31, 2022, at 12:30 PM, you would execute the following command:
touch -t 202312311230 custom.txt
touch command, the timestamp for the
-t option follows a specific format:
Here's a breakdown of each component:
CC: Represents the first two digits of the year (century).
YY: Represents the last two digits of the year.
MM: Represents the month (01-12).
DD: Represents the day of the month (01-31).
hh: Represents the hour in 24-hour format (00-23).
mm: Represents the minute (00-59).
.ss: (Optional) Represents the second (00-61).
In your example, the timestamp
202312311230 corresponds to the following components:
CC: Not specified, assuming it is the current century.
22(indicating the year 2023).
31(indicating the 31st day of the month).
12(indicating 12 PM).
30(indicating 30 minutes).
This command will set the modification and access times of the
custom.txt file to the specified timestamp, allowing you to manually define the file's timestamp.
less is a program that lets us view text files. This is very handy since many of the files used to control and configure Linux are human-readable.
q to quit or keep clicking enter till you are done reading the file.