Basic Linux Commands: Discovering and Using Linux Command
Basic Linux Commands: Discovering and Using Linux Command
The /etc/passwd file contains a list of the usernames and their respective attributes, such as User ID
(UID), Group ID (GID), User ID info, home directory, and shell. Interesting enough, it doesn’t
normally store the user’s password; another file, called the shadow file (/etc/shadow), now contains a
hashed version of the user’s password.
The shell uses a blank space or a tab to distinguish between the command and options.
This means that you must use a space or a tab to separate the command from the options and the
options from one another. If an option contains spaces, you put that option inside quotation marks. For
example, to search for a name in the password file, enter the following grep command (grep is used
for searching for text in files): grep "Jon B" /etc/passwd
If a command is too long to fit on a single line, you can press the backslash key (\) followed by Enter.
Then continue typing the command on the next line. For example, type the following command (press
Enter after each line):
cat \
/etc/passwd
You can concatenate (that is, string together) several shorter commands on a single line by separating
the commands with semicolons (;). For example, the following command changes the current
directory to your home directory, lists the contents of that directory, and then shows the name of that
directory:
cd; ls -l; pwd
Maintaining the OS
Depending on the version, you will have one of two tools: the Advanced Package Tool (APT) or
Yellowdog Updater, Modified (YUM).
Linux distributions, such as Ubuntu, Debian, and Mint, will use the APT package management tool.
In the operating system you can update the repositories by using the apt command or the apt-get
command.
Sudo apt-get update
Sudo apt-get upgrade
The YUM package manager is used to update and install packages for Red Hat–based Linux
distributions, such as Red Hat Enterprise Server, Fedora, and CentOS.
yum update
yum upgrade
Now that you know how to update the operating system and install packages, it’s inevitable that you’ll
run out of space on the operating system. Fortunately, you can monitor and quickly find out how
much space is free on the disk by using the df command, otherwise known as the disk free command.
By using the df command you can quickly see the percentage of free space, and if you supply the -h
argument you’ll get results in human-readable formats of bytes, as shown here:
user@server:~$ df -h