screen is a powerful terminal session manager with many use cases. One such use case is to start a long-running Command Line Interface (CLI) program in a terminal session, detach the session while leaving the program running unattended, logout, and return to the same session later from another terminal. Let's examine how you would use screen in a real-life situation. Imagine the time is 15 minutes to the end of your work day. But before you can leave, you have to run a program that will run for an hour.
Often, ssh is configured to disallow root to login directly. To login, root first logins as a non-privileged user, and then do a sudo to become root. There can be many reasons why you don't want root to login directly. You may be concerned about security. Brute force attacks by guessing the password are common. In addition to security, you may be concerned about traceability.
Youtube is a great source for watching videos or listening to music on-line via their website. But if you want to download the video or audio to your computer, you need some special tool, and you need to know the URL for the youtube video you wish to download. One such tool is youtube-dl, which is a python script. Unfortunately, youtube-dl is not pre-packaged with Debian Wheezy. I downloaded the script directly from this web page: $ sudo curl https://yt-dl.org/downloads/2013.09.24.2/youtube-dl -o /usr/local/bin/youtube-dl
In the modern networked environment, we often wish to run an application on a remote host while we are comfortably logged in on our local computer. Assuming both machines are Linux-based, and the application runs on the graphical X desktop, the following approaches come to mind:
This article focuses only on X11 forwarding. X11 forwarding over SSH enables you to run a remote X app and display it locally, with traffic between the 2 hosts encrypted by SSH.
You already know how to execute a command on a remote computer via ssh. The syntax is like this: $ ssh firstname.lastname@example.org This will work if the command is simply piping output, for example, ls. If the command is "screen-based" in that it interprets user input, you may get an error. The following shows what happens when you ssh to run such programs (e.g., top, emacs, screen). $ ssh email@example.com firstname.lastname@example.org's password: TERM environment variable not set.
To shutdown the local machine immediately, you execute this command as root or under sudo: $ shutdown -h nowIf it is a remote server that you want to shutdown, it could be slightly more involved. You need to have root privileges to shutdown a machine. However, many systems are configured to block root from logging in remotely usingssh. So, you need to ssh in as a regular, non-root user, and pass the sudo command to shutdown host. $ ssh -t email@example.com 'sudo shutdown -h now'
Occasionally, I want to copy a short line of text to a remote computer. For instance, I have an URL for some real cool web site which, for whatever reason, I want to send to a remote host. I can always put the text in a file, and transfer it via scp. $ cat > coolurl.txthttp://really-cool-web-site/$ scp coolurl.txt firstname.lastname@example.org:Or, you can use the following one-liner command: $ echo 'http://really-cool-web-site/'|ssh email@example.com 'cat >coolurl.txt'
Some machines have access to more than one printer. Unless the default printer is the one you want, you need to know the name of the printer to use in the printer-related command. For instance, if you want to know the status of a printer, you execute the lpq command: $ lpqml1640 is readyno entries
I was tasked to upgrade the mysql server running on the Centos server. Of course, the first thing I should do was to backup my database. I run the mysqldump command below to write out the sql statements that will re-create and populate the database tables. # mysqldump -uroot -p -l --opt --all-databases=true > /root/mysqlall.sqlmysqldump: Couldn't execute 'show fields from `asset`': Got error 28 from storage engine (1030)
I often ssh to different servers, both at work and at home. Often, the Linux account name is different according to which server I'm logging in. Also, some servers are set up to allow ssh login through a different port than the default port 22. For instance, to login to 220.127.116.11, I need to type all this in: # ssh -p 2222 firstname.lastname@example.org