Linux Commands Flashcards
cal
Shows system calendar
date
Shows date
df
To see the current amount of free space on your disk drives
free
to display the amount of free memory
exit
to end a terminal session
Ctrl- Alt-F1 through Ctrl-Alt-F6
To access virtual terminals or virtual consoles
Alt and F1-F6
To switch from one virtual console to another
Alt-F7
To return to the graphical desk- top
pwd
Print name of current working directory
cd (argument)
Change directory
ls
List current working directory contents
.
The “.” symbol refers to the working directory
..
the “..” symbol refers to the working directory’s parent directory
cd
Changes the working directory to your home directory
cd -
Changes the working directory to the previous working directory
cd ~user_name
Changes the working directory to the home directory of user_name
ls -a
Shows hidden files
ls (arg) (arg) …
To list the contents of one or more directories
ls -l
By adding “-l” to the command, we changed the output to the long format
command -options arguments
Overall style of a command
ls -lt
many commands allow multiple short options to be strung together. In this example, the ls command is given two options, the “l” option to produce long format output, and the “t” option to sort the result by the file’s modification time
ls -lt –reverse
Long options are preceded with two dashes
ls -a
ls –all
List all files, even those with names that begin with a period, which are normally not listed (i.e., hidden)
ls -A
ls –almost-all
Like the -a option above except it does not list . (current directory) and .. (parent directory)
ls -d
ls –directory
Ordinarily, if a directory is specified, ls will list the contents of the directory, not the directory itself. Use this option in conjunction with the -l option to see details about the directory rather than its contents
ls -F
ls –classify
This option will append an indicator character to the end of each listed name. For example, a “/” if the name is a directory
ls -h
ls –human-readable
In long format listings, display file sizes in human readable format rather than in bytes
ls -l
Display results in long format
ls -r
ls –reverse
Display the results in reverse order. Normally, ls displays its results in ascending alphabetical order
ls -S
Sort results by file size
ls -t
Sort by modification time
ls Long Listing Fields:
-rw-r–r–
Access rights to the file. The first character indicates the type of file. Among the different types, a leading dash means a regular file, while a “d” indicates a directory.
The next three characters are the access rights for the file’s owner, the next three are for members of the file’s group, and the final three are for everyone else. The full meaning of this is discussed in Chapter 9 – Permissions
ls Long Listing Fields:
1
File’s number of hard links. See the discussion of links later in this chapter
ls Long Listing Fields:
root
The username of the file’s owner
ls Long Listing Fields:
root
The name of the group which owns the file
ls Long Listing Fields:
32059
Size of the file in bytes
ls Long Listing Fields:
2007-04-03 11:05
Date and time of the file’s last modification
ls Long Listing Fields:
oo-cd-cover.odf
Name of the file
file (filename)
the file command will print a brief description of the file’s contents
less (filename)
the less program allows you to scroll forward and backward through a text file.
Once the less program starts, we can view the contents of the file. If the file is longer
than one page, we can scroll up and down. To exit less, press the “q” key.
less Commands:
Page Up or b
Scroll back one page
less Commands:
Page Down or space
Scroll forward one page
less Commands:
Up Arrow
Scroll up one line
less Commands:
Down Arrow
Scroll down one line
less Commands:
G
Move to the end of the text file
less Commands:
1G or g
Move to the beginning of the text file
less Commands:
/characters
Search forward to the next occurrence of characters
less Commands:
n
Search for the next occurrence of the previous search
less Commands:
h
Display help screen
less Commands:
q
Quit less
Directories Found On Linux Systems:
/
The root directory. Where everything begins.
Directories Found On Linux Systems:
/bin
Contains binaries (programs) that must be present for the system to boot and run.
Directories Found On Linux Systems:
/boot
Contains the Linux kernel, initial RAM disk image (for drivers needed at boot time), and the boot loader.
Interesting files:
● /boot/grub/grub.conf or menu.lst, which
are used to configure the boot loader.
● /boot/vmlinuz, the Linux kernel
Directories Found On Linux Systems:
/dev
This is a special directory which contains device nodes. “Everything is a file” also applies to devices. Here is where the kernel maintains a list of all the devices it understands.
Directories Found On Linux Systems:
/etc
The /etc directory contains all of the system-wide configuration files. It also contains a collection of shell scripts which start each of the system services at boot time. Everything in this directory should be readable text.
Interesting files: While everything in /etc is interesting, here are some of my all-time favorites:
● /etc/crontab, a file that defines when automated jobs will run.
● /etc/fstab, a table of storage devices and their associated mount points.
● /etc/passwd, a list of the user accounts.
Directories Found On Linux Systems:
/home
In normal configurations, each user is given a directory in /home. Ordinary users can only write files in their home directories. This limitation protects the system from errant user activity.
Directories Found On Linux Systems:
/lib
Contains shared library files used by the core system programs. These are similar to DLLs in Windows.
Directories Found On Linux Systems:
/lost+found
Each formatted partition or device using a Linux file system, such as ext3, will have this directory. It is used in the case of a partial recovery from a file system corruption event. Unless something really bad has happened to your system, this directory will remain empty.
Directories Found On Linux Systems:
/media
On modern Linux systems the /media directory will contain the mount points for removable media such as USB drives, CD-ROMs, etc. that are mounted automatically at insertion.
Directories Found On Linux Systems:
/mnt
On older Linux systems, the /mnt directory contains mount points for removable devices that have been mounted
manually.
Directories Found On Linux Systems:
/opt
The /opt directory is used to install “optional” software. This is mainly used to hold commercial software products that may be installed on your system.
Directories Found On Linux Systems:
/proc
The /proc directory is special. It’s not a real file system in the sense of files stored on your hard drive. Rather, it is a virtual file system maintained by the Linux kernel. The “files” it contains are peepholes into the kernel itself. The files are readable and will give you a picture of how the kernel sees your computer.
Directories Found On Linux Systems:
/root
This is the home directory for the root account.