| By detrate |
IntroductionThis article is touches upon learning how to leverage some of the real power of Linux via the terminal. As such, the terminal is required for this article/tutorial. You will find the terminal at Applications > Accessories > Terminal.
The terminal gives you full control of everything behind the scenes. The ability to manipulate processes (top), install and remove software (aptitude), change file permissions (chmod) and basically anything you can do with a GUI and more. You have to keep in mind, Linux has evolved into the desktop we know today from a server operating system.
Typically, unless you’re a power-user you don’t have much interest in the terminal unless you’re reading a tutorial that gives commands and you can just paste them to get things setup. I want to break you of that habit and introduce some common ways to access media via the terminal. When you mix the following techniques with other commands such as ‘locate’ or ‘find’ as I’ve discussed on my blog, you won’t even think twice about opening a gui to search for and open your media.
Of course, the first step in making using the terminal more habitual is to provide quick access, so lets get on with the tutorial.
Quick Access to the TerminalIf you plan on using the terminal often I suggest setting up a hot-key to provide yourself with quick access. In GNOME, the fastest way to access your keybinds is by typing “gnome-keybinding-properties” in terminal as the screenshot below illustrates. I typed gnome- [tab][tab] to show you a list of GNOME applications accessible via the terminal.
So go ahead and type:
gnome-keybinding-properties
I set mine to ctrl+alt+t, but you can set yours to whatever you like
If you use compiz, like me, you have another option available for you to set hot-keys and pass parameters. Under “commands” in CompizConfig Settings Manager (ccsm), you’ll see how I’ve set a command to open gnome-terminal with a specific geometry.
Opening a Graphical File Browser via the TerminalIf you’re new to Ubuntu or linux in general, chances are you’re unfamiliar with the name of specific applications, especially those integrated tightly with the window manager. Gnome calls it’s file browser Nautilus.
The syntax for opening a folder with nautilus is:
nautilus /path/to/file
Where in this case, ‘/path/to/file’ is “current directory” or “.”.
A little trick to help you “explore” a directory, is to add an “explore” alias to your .bashrc file that will open nautilus in the current directory.
echo -e "\nalias explore='nautilus --browser .'" >> ~/.bashrc && source ~/.bashrc
The command above echos text with a line break preceding it and redirects the output to your .bashrc file, a file that is called when you start up a terminal session. It then “sources” that file, refreshing and applying its contents to your current session, making the command “explore” active instantly.
Viewing and Editing Text FilesViewing and editing text is a pretty simple task for the terminal but not always for the user. The simplest way to view text in the terminal is with the “more” command, which was created before the “less” command, which allows you to scroll up and down. If you’re unfamiliar with some of the obscure (but powerful) input methods in terminal based editors like emacs or vim, it’s recommended you open the files with a graphical editor. The default in GNOME is gedit.
In the screenshot above I use the following two commands:
more filename.txt
gedit filename.txt
In the screenshot below, you’ll see a “^C”, this is because I used to the command escape key sequence, ctrl (^) + C. You can use this to kill almost any command.
Viewing VideosAnother one of those program names that gets masked by GNOME / Ubuntu is “totem” the default video player.
The syntax is:
totem /path/to/filename
Since I was in the directory to the file, no path was needed and I was able to just type the filename.
Viewing ImagesAnother one of those program names that gets masked by GNOME / Ubuntu is Eye Of Gnome, “eog” the default image view.
The syntax is:
eog /path/to/filename
Since I was in the directory to the file, no path was needed and I was able to just type the filename.
Playing AudioOpening or appending music to a playlist in Rhythmbox is pretty straight forward.
The syntax is:
rhythmbox /path/to/filename
Since I was in the directory to the file, no path was needed and I was able to just type the filename.
The interesting this above this example, is that I’ve shown how to deal with spaces in file names 1 of 2 ways. The first is harder to understand because it’s using backslashes (\) to tell the terminal the next character is a space in the file name and not a break in the command. This way is less readable and I prefer quoting as I’ve shown in the second example.
One command to rule them allMy friend Bruce has brought it to my attention that two utilities exist to help you open any sort of media based on your mime-type associations. Those two commands are:
xdg-open
and
gnome-open
which can handle more than your standard media, for instance, URLs
xdg-open http://www.ubuntumagazine.net
xdg-open file.txt
xdg-open video.ogv
xdg-open music.ogg
xdg-open picture.png
etc.
ConclusionI hope this introduction to accessing your media via the terminal is enough to entice you into using it more. It’s a very powerful tool and a large part of what I find so attractive about Linux. Don’t be afraid to try more commands from the terminal, just make sure you know what you’re doing. If you ever feel lost in the terminal, try typing ‘man ‘ i.e.
man ls
to provide yourself with the commands ‘manual page’. It may seem a bit intimidating at first but quickly it becomes second nature and you learn to skim through for exactly what you need.
For more info about terminal commands, feel free to check out my blog at http://www.doknowevil.net
Best of luck, have fun in the terminal!
Please, help us to keep this free project updated and alive. THANKYOU!
IntroductionThis article is touches upon learning how to leverage some of the real power of Linux via the terminal. As such, the terminal is required for this article/tutorial. You will find the terminal at Applications > Accessories > Terminal.
The terminal gives you full control of everything behind the scenes. The ability to manipulate processes (top), install and remove software (aptitude), change file permissions (chmod) and basically anything you can do with a GUI and more. You have to keep in mind, Linux has evolved into the desktop we know today from a server operating system.
Typically, unless you’re a power-user you don’t have much interest in the terminal unless you’re reading a tutorial that gives commands and you can just paste them to get things setup. I want to break you of that habit and introduce some common ways to access media via the terminal. When you mix the following techniques with other commands such as ‘locate’ or ‘find’ as I’ve discussed on my blog, you won’t even think twice about opening a gui to search for and open your media.
Of course, the first step in making using the terminal more habitual is to provide quick access, so lets get on with the tutorial.
Quick Access to the TerminalIf you plan on using the terminal often I suggest setting up a hot-key to provide yourself with quick access. In GNOME, the fastest way to access your keybinds is by typing “gnome-keybinding-properties” in terminal as the screenshot below illustrates. I typed gnome- [tab][tab] to show you a list of GNOME applications accessible via the terminal.
So go ahead and type:
gnome-keybinding-properties
I set mine to ctrl+alt+t, but you can set yours to whatever you like
If you use compiz, like me, you have another option available for you to set hot-keys and pass parameters. Under “commands” in CompizConfig Settings Manager (ccsm), you’ll see how I’ve set a command to open gnome-terminal with a specific geometry.
Opening a Graphical File Browser via the TerminalIf you’re new to Ubuntu or linux in general, chances are you’re unfamiliar with the name of specific applications, especially those integrated tightly with the window manager. Gnome calls it’s file browser Nautilus.
The syntax for opening a folder with nautilus is:
nautilus /path/to/file
Where in this case, ‘/path/to/file’ is “current directory” or “.”.
A little trick to help you “explore” a directory, is to add an “explore” alias to your .bashrc file that will open nautilus in the current directory.
echo -e "\nalias explore='nautilus --browser .'" >> ~/.bashrc && source ~/.bashrc
The command above echos text with a line break preceding it and redirects the output to your .bashrc file, a file that is called when you start up a terminal session. It then “sources” that file, refreshing and applying its contents to your current session, making the command “explore” active instantly.
Viewing and Editing Text FilesViewing and editing text is a pretty simple task for the terminal but not always for the user. The simplest way to view text in the terminal is with the “more” command, which was created before the “less” command, which allows you to scroll up and down. If you’re unfamiliar with some of the obscure (but powerful) input methods in terminal based editors like emacs or vim, it’s recommended you open the files with a graphical editor. The default in GNOME is gedit.
In the screenshot above I use the following two commands:
more filename.txt
gedit filename.txt
In the screenshot below, you’ll see a “^C”, this is because I used to the command escape key sequence, ctrl (^) + C. You can use this to kill almost any command.
Viewing VideosAnother one of those program names that gets masked by GNOME / Ubuntu is “totem” the default video player.
The syntax is:
totem /path/to/filename
Since I was in the directory to the file, no path was needed and I was able to just type the filename.
Viewing ImagesAnother one of those program names that gets masked by GNOME / Ubuntu is Eye Of Gnome, “eog” the default image view.
The syntax is:
eog /path/to/filename
Since I was in the directory to the file, no path was needed and I was able to just type the filename.
Playing AudioOpening or appending music to a playlist in Rhythmbox is pretty straight forward.
The syntax is:
rhythmbox /path/to/filename
Since I was in the directory to the file, no path was needed and I was able to just type the filename.
The interesting this above this example, is that I’ve shown how to deal with spaces in file names 1 of 2 ways. The first is harder to understand because it’s using backslashes (\) to tell the terminal the next character is a space in the file name and not a break in the command. This way is less readable and I prefer quoting as I’ve shown in the second example.
One command to rule them allMy friend Bruce has brought it to my attention that two utilities exist to help you open any sort of media based on your mime-type associations. Those two commands are:
xdg-open
and
gnome-open
which can handle more than your standard media, for instance, URLs
xdg-open http://www.ubuntumagazine.net
xdg-open file.txt
xdg-open video.ogv
xdg-open music.ogg
xdg-open picture.png
etc.
ConclusionI hope this introduction to accessing your media via the terminal is enough to entice you into using it more. It’s a very powerful tool and a large part of what I find so attractive about Linux. Don’t be afraid to try more commands from the terminal, just make sure you know what you’re doing. If you ever feel lost in the terminal, try typing ‘man ‘ i.e.
man ls
to provide yourself with the commands ‘manual page’. It may seem a bit intimidating at first but quickly it becomes second nature and you learn to skim through for exactly what you need.
For more info about terminal commands, feel free to check out my blog at http://www.doknowevil.net
Best of luck, have fun in the terminal!
Please, help us to keep this free project updated and alive. THANKYOU!
.You must be logged in to post a comment