I am a new Linux bash shell command line user. How can I view a text file using command line on a Linux or Unix-like operating systems? How can I view (open) binary files such as PDF or images on a Linux or Unix like system from command line? Also, How do I list the files in a directory stored on my Unix box?
You can use any one of the following command to view a text file or any other files such as PDF, doc, image, video, music/mp3 and more.
If you are using OS X Unix try open command as follows:
How do I list the files in a directory on Unix?
To see or list the files in a directory on Linux, run ls command: ls ls -l If you would like to see and list files in another directory, use the ls along with the path to the directory: ls /usr/ ls -l /etc/ ## just list resolv.conf file # ls -l /etc/resolv.conf
Common ls command options
The syntax is: ls [options] file Where options for ls are:
-l : Use a long listing format to display Linux/Unix file names.
-a : Do not ignore entries starting with . (period). Display all hidden files.
-d : List Linux directories themselves, not their contents
-R : List sub-directories recursively on Linux
-F : Append indicator for file. For example, / for directories, * for executable Linux files, @ for symbolic links and more
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.