Menu Close

Command line tips

The command-line

Try it, it’s really not that bad
The command-line really is your friend. After opening Terminal from the Applications>Accessories menu (or Konsole in KDE), you can accomplish many common tasks much more effectively than from any desktop GUI. To copy folder, for example, type ‘cp -rf source destination’, rename a file with ‘mv’ and edit a text file using a command called ‘nano’.

 

Easy command shortcuts
You can press the tab key while using the command-line to automatically complete command names as well as system paths. You can also cursor up through your command history, and use ‘Ctrl + r’ to search for a command starting with the characters you begin to type.

Replace heavy GUI applications with command-line equivalents
There are command-line versions of most desktop applications. You could install and use ‘pine’ for your email and news, for instance. Or try ‘lynx’ for web browsing and ‘wget’ or ‘ncftp’ for downloading files. ‘mc’, short for Midnight Commander, is a feature-full file manager, and all of these tools will run on hardly any memory with hardly any CPU requirements.

Create an ISO image from a CD or a DVD
You can create an ISO image from optical media, and most attached devices, by using a single command on the terminal. Type ‘dd if=/dev/cdrom of=disk.iso bs=1024’ to make a raw copy of the data and drop it into the disk.iso file. You may need to unmount the drive first, by typing ‘sudo umount /dev/cdrom’.

Read an ISO disc image without burning it
If you’ve downloaded an ISO disc image, and you want to access the files on it without wasting an optical disk, you can create a virtual drive from the image with a single command. Open the terminal from the Accessories menu. Type ‘sudo mkdir /mnt/image’, followed by ‘sudo mount -o loop disk.iso /mnt/image’. You can now browse the disc by pointing a file browser at the ‘/mnt/image’ folder.

Use the ‘screen’ command
After you’ve got used to the command-line, one of the best commands to learn is called ‘screen’. It’s the command equivalent to virtual desktops, and it lets you run several sessions at once, as well as suspend and resume a session. Type ‘screen’ to start, then press ‘Ctrl a’ followed by ‘c’ to create a new session. ‘Ctrl a’ and ‘n’ or ‘p’ will switch through the active sessions. ‘Ctrl a’ and ‘d’ will detach from the session, while typing ‘screen -r’ will resume one.

Access your Ubuntu machine from anywhere
The best thing about the command-line is that you can use it to access your machine securely from anywhere on the internet. The key to this is something called ‘SSH’ – the secure shell. Install ‘openssh-server’ through Synaptic and use a tool called ‘putty’ on a Windows machine, or ‘ssh’ on Linux, to access the command-line through your user accounts on your Ubuntu box.

Transfer files between computers files quickly and securely
With the open SSH server installed and running, you can quickly and securely transfer files to and from the remote computer using the ‘sftp’ command. It works just like FTP, and accepts both ‘put’ and ‘get’ for file tranfers. If you prefer a GUI, we recommend using Filezilla on Windows, or ‘sftp://’ as a protocol in KDE.

Avoid typing ‘sudo’
You might have noticed that for almost every important configuration command you type, you need to precede it with ‘sudo’ and your password. This can be a real pain if you’re typing one sudo command after the other. Avoid this hassle by typing ‘sudo bash’, this transparently replaces the current shell with a new one, complete with administrator privileges.

Create a root account
If you find yourself spending more and more time requiring system administration privileges, you may as well enable the root account. Just type ‘sudo passwd root’, and enter your password followed by a new one for the root account. You can now type ‘su root’ to login as root, but you should only use this mode for essential system maintenance.

14 total views, 1 views today

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Linux Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of
Linux
Guest

You made some clear points there. I did a search on the subject and found most guys will consent with your site.