-1

I am a new user to Linux. I have several files and documents in my directory and sometimes when I want to read or display data in these files, I do not know which command I need to type for this purpose. I would be appreciated if one helps me with that.

6
  • 1
    Given a file named foo, type file foo. It will tell you what type of file it is, which should give you a clue as to what program to read it with. – G-Man Says 'Reinstate Monica' Aug 19 '14 at 21:28
  • I tried to use this command with different files with different end forma,i.e docx, xlsx and pdf but each time I get this massage (No such file or directory) although these files are actually found. – user1 Aug 19 '14 at 21:40
  • In that case, you have a bigger problem than identifying "which command" goes with which file type. See Files listed by bash but unaccessible (or inaccessible). – G-Man Says 'Reinstate Monica' Aug 19 '14 at 21:56
  • You mean desktop environment, not console, right? Please specify that, beacause most answers focus on console. – Kamil Aug 19 '14 at 23:39
  • @Kamil My answer covers both text terminals and graphic/desktop (X) applications. – vinc17 Aug 20 '14 at 0:06
4

If you want to display text in the terminal, with automatic conversion to text, you can use less <file> with Wolfgang Friebel's lesspipe, which will detect some file types and do the conversion transparently.

For graphic applications, you can use xdg-open <file>, which will automatically select the "right" application.

1

There are a few commands you can type to view contents of files. There are:

  • vim or vi which is good for viewing text files and creating shell scripts
  • less or more which is good for viewing log files ( I find less more useful in that case). You cannot change anything with less or more but is good for viewing.
  • gedit which is a GUI tool that will show text/log/conf files.
  • cat can show contents of a file but your better off using less
4
  • Thanks for you all. I tried all your suggestions but each time I get either errors (-bash: syntax error near unexpected token `newline') or (Missing name or redirect). – user1 Aug 20 '14 at 13:42
  • What exactly are you typing in? – ryekayo Aug 20 '14 at 13:42
  • As I indicated previously, I am trying to view of read the content of some files on Xterm for Linux desktop. For example a file with pdf or psk format. – user1 Aug 20 '14 at 14:13
  • Do you have a pdf viewer installed? Can you type: man -k pdf – ryekayo Aug 20 '14 at 14:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.