ls : What's in This Directory?
The command ls stands for list directory contents. And, cleverly, it will do just that: list a directory's contents! Using it with -F will give a list of the directories contents, and denote items that are other directories with a trailing /.
On my server returns:
allthethings.txt important.doc Indominus/ Misc/ probs.xls Red Wings/ Spreadsheets/ Work/
In the above case, allthethings.txt, garbage.file, important.doc, and probs.xls are files, and Indominus, Misc, Red Wings, Spreadsheets, and Work, each with the trailing /, are directories!
There are many other options, or switches, such as -F that can be used with ls for improved results. For example:
dr-xr-x---. 10 root root 4096 Apr 17 12:01 . drwxr-xr-x. 19 root root 4096 Apr 14 12:45 .. -rw-r--r-- 1 root root 0 Apr 17 12:00 allthethings.txt -rw------- 1 root root 483 Apr 14 12:45 .bash_history -rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout -rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile -rw-r--r--. 1 root root 361 Jan 1 01:24 .bashrc drwxr-xr-x 3 root root 4096 Jan 1 01:25 .cache/ drwxr-xr-x 3 root root 4096 Jan 1 01:25 .config/ -rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc -rw-r--r-- 1 root root 0 Apr 17 12:01 garbage.file -rw-r--r-- 1 root root 0 Apr 17 11:58 important.doc drwxr-xr-x 2 root root 4096 Apr 17 11:59 Indominus/ drwxr-xr-x 2 root root 4096 Apr 17 11:57 Misc/ -rw------- 1 root root 42 Apr 14 12:44 .my.cnf -rw-r--r-- 1 root root 0 Apr 17 12:00 probs.xls drwxr-xr-x 2 root root 4096 Apr 17 11:57 Red Wings/ -rw------- 1 root root 1024 Jan 1 01:22 .rnd drwxr-xr-x 2 root root 4096 Apr 17 11:56 Spreadsheets/ drw------- 2 root root 4096 Apr 14 12:42 .ssh/ -rw-r--r--. 1 root root 129 Dec 28 2013 .tcshrc drwxr-xr-x 2 root root 4096 Apr 17 11:57 Work/
In the above case two switches are added: -l and -a. The -l uses the long listing format, and the -a switch lists all the files, including hidden files.
Each column contains an important bit of information:
Column | Information | Example
- 1 | Permissions | drwxr-xr-x
- 2 | # of Hard Links | 2
- 3 | User That Owns File or Directory | root
- 4 | Group for File or Directory | root
- 5 | File Size | 4096
- 6 | Timestamp | Apr 17 11:59
- 7 | Filename | Indominus/
pwd : What Directory Am I Running Commands In?
Before deleting anything, it's always helpful to know what directory you're in; the pwd command will tell you and stands for present working directory:
Returns the full path name:
Checking the present working directory can prevent errors when you're using commands that will remove files or directories... in fact, it can save you from a lot of stress and headache!
cd : Move Me to This Other Directory! Stat!
The cd command stands for change directory and is used extremely frequently.
For example, if you're currently in your home directory /home/dinosaursareawesome:
But want to change to another directory within that directory... say... Velociraptor:
ls -laF ls -laF
Then you can use the following command to change to Velociraptor:
And then verify that you made it to the right directory:
touch : Create This File, or Update the Timestamp on That File!
The touch command is generally used to change file timestamps, but it can also be used for creating a new file.
Let's look at changing a time stamp first. In the case below, I have a file named Foxtrot in the current directory, that was created on Apr 14 12:46:
ls -laF drwxr-xr-x 2 root root 4096 Apr 17 16:54 ./ drwxr-xr-x 3 root root 4096 Apr 17 16:44 ../ -rw-r--r-- 1 root root 5262 Apr 14 12:46 Foxtrot
Now, let's say I wanted to update that timestamp, Apr 14 12:46 to the current timestamp, but without changing the file. Simply touch the file:
And then check the new timestamp and you'll see it has been updated to the current time, which for me is Apr 17 17:01:
ls -laF drwxr-xr-x 2 root root 4096 Apr 17 16:54 ./ drwxr-xr-x 3 root root 4096 Apr 17 16:44 ../ -rw-r--r-- 1 root root 5262 Apr 17 17:01 Foxtrot
The second use of the command is to create a file. Let's say I wanted to create the file Golf in my present working directory:
Now look for your new file:
ls -laF drwxr-xr-x 2 root root 4096 Apr 17 17:04 . drwxr-xr-x 3 root root 4096 Apr 17 16:44 .. -rw-r--r-- 1 root root 5262 Apr 17 17:01 Foxtrot -rw-r--r-- 1 root root 0 Apr 17 17:04 Golf
history : What Have I Done and With Which Commands?
The history command will print a history of all the previously executed commands by the current user. For example:
history 95 20150417 - 17:01:48 - touch Foxtrot 96 20150417 - 17:01:50 - ls -laF 97 20150417 - 17:04:06 - touch Golf 98 20150417 - 17:04:07 - ls -la
uname : What version am I running?
The uname command is most commonly used to determine which OS you're running, its version, and the kernel version. With the -a switch, it will show: 1. kernel name, 2. network node hostname, 3. kernel release, 4. kernel version, 5. machine hardware name, processor type or "unknown", 6. hardware platform or "unknown", and 7. the operating system.
uname -a Linux centos7core.thebestfakedomainnameintheworld.com 3.10.0-123.13.2.el7.x86_64 #1 SMP Thu Dec 18 14:09:13 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
- Kernel Name: Linux
- Network Node Hostname: centos7core.thebestfakedomainnameintheworld.com
- Kernel Release: 3.10.0-123.13.2.el7.x86_64
- Kernel Version: #1 SMP Thu Dec 18 14:09:13 UTC 2014
- Machine Hardware Name: x86_64
- Processor Type: x86_64
- Hardware Platform: x86_64
- Operating System: GNU/Linux
man : Help! What Does This Command Do?!
The man command opens manual pages for individual commands; basically, it's your access to quick information on any command. For example, if you wanted to read the manual page for ls, then you would run:
That's it! Help is that easy to access in Linux!
Our Support Teams are replete with talented Linux technicians and System administrators who have an intimate knowledge of multiple web hosting technologies, especially those discussed in this article.
If you are a Fully Managed VPS server, Cloud Dedicated, VMWare Private Cloud, Private Parent server or a Dedicated server owner and you are uncomfortable with performing any of the steps outlined, we can be reached via phone @800.580.4985, a chat or support ticket to assisting you with this process.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.