Command Line - Files and Directories
Where are my files?
Now that we are able to navigate on the command line the next question is: how do I find out what files are in my directory? To view the content of a directory use the command ll (short for long list, i.e., a long version of the default command ls = list) which shows one line per file, program or directory in the specified location:
course_user> ll
d rwxr-xr-x 2 course_user staff 68 17 Jul 10:32 Files
d rwxr-xr-x 2 course_user staff 68 2 Oct 2020 Workshops
d rwxr-xr-x 2 course_user staff 68 22 Feb 14:02 meeting_notest
- rw-r--r-- 1 course_user staff 152 17 Jul 10:32 sequences.fasta
- rw-r--r-- 1 course_user staff 1551 17 Jul 10:32 to-do.txt
Wow, ok, we can see that there are a lot of things in there. Let’s take a closer look: first of all we see that the output of ll consists of ten columns:
1 2 3 4 5 6 7 8 9 10
d rwxr-xr-x 2 course_user staff 68 17 Jul 10:32 Files
d rwxr-xr-x 2 course_user staff 68 2 Oct 2020 Workshops
d rwxr-xr-x 2 course_user staff 68 22 Feb 14:02 meeting_notest
- rw-r--r-- 1 course_user staff 152 17 Jul 10:32 sequences.fasta
- rw-r--r-- 1 course_user staff 1551 17 Jul 10:32 to-do.txt
- Type, d = directory, - = file
- Access rights,ie., who is allowed to read (r), write (w) or execute the file/directory.
- Link Count
- Owner of the file/directory
- Group the file/directory belongs to
- Size in bytes
- Day it was created/last modified
- Month it was created/last modified
- Time (if this year) or year it was created/last modified
- Name of the file/directory
For beginners, the columns of most importance are usually
- 1 - Is it a file or a directory?
- 4 - Who does the file belong to?
- 6 - How big is a file?
- 10 - What is the name of the file/directory?
Many CLIs also distinguish the type of a directory item by colour: directories are shown in blue, files in black. For example, the same directory structure on my laptop looks like this:
Also, as you can see, the first two columns often look like one column.
With this knowledge we can now properly interpret the output of ll of our current working directory:
- It contains 3 directories: Files, Workshops, and meeting_notest
- It contains 2 files: sequence.fasta, and to-do.txt
- All files were created by me (user tim)
- The file sequences.fasta is 251 bytes and file to-do.txt is of size 1551 bytes