- The Linux Command Line
- by William Shotts
- What Readers Are Saying About The Linux Command Line!
- How to Compress PDF in Linux [GUI & Terminal]
- Method 1: Reduce PDF file size in Linux command line
- Method 2: Compress PDF files in Linux using GUI tool
- How to Use «Script» Command to Record Linux Terminal Session
- How does script command work?
- 1. Record your terminal session
- 2. Check the content of a recorded terminal session
- 3. Record several terminal session
- 4. Replay a linux terminal session
- Conclusion
The Linux Command Line
by William Shotts
Fifth Internet Edition Available Now!
Designed for the new command line user, this 555-page volume covers the same material as LinuxCommand.org but in much greater detail. In addition to the basics of command line use and shell scripting, The Linux Command Line includes chapters on many common programs used on the command line, as well as more advanced topics.
Released under a Creative Commons license, this book is available for free download in PDF format. Download it here.
The book is available in printed form, published by No Starch Press. Copies may be purchased wherever fine books are sold. No Starch Press also offers electronic formats for popular e-readers.
In addition to English, the printed book is also available in the following languages:
- Korean: available from BJ PUBLIC
- Serbian: available from Mikro Knjiga
- Chinese (Traditional): available from GOTOP
- Chinese (Simplified): available from PT Press
- Russian: available from Piter
- Polish: available from Helion
Find The Linux Command Line at your local library.
Want to translate the Creative Commons version of The Linux Command Line? Please see the Community Translation Policy for details.
The following community translations are now available:
- ArabicTranslation by Abd Allatif Eymsh
- Spanish (in progress). Translation by Adriano Sánchez
- Portuguese (in progress). Translation by Matheus Sales
- Italian (in progress). Translation by Francesco Cargiuli
- Romanian (in progress). Translation by Vlad Paval
- Turkish (in progress). Translation by Herkes için Linux
What Readers Are Saying About The Linux Command Line!
«I have been using Linux for a little over a year. Read as much as I could including Rute, and many others. I have learned more in the first 93 pages of your book than any others. «
«What a great help your book has been for me! I was looking for a book like yours, but I never was able to find one that really walks the reader through the Linux command line in a general sort of way. Do you know of any others? If I recall, there are a lot of books dedicated to shell scripting, but none that are geared to regular command-line use.»
«Fantastic book!! I have recently switched from the legacy OS to Linux and I have been trying to find a distro that mimics this legacy OS in fear of using the terminal. I ran across this book and opened the terminal for the first time. This book teaches you everything you need to know about the shell and does it with ease. It starts by giving you a solid foundation and builds from there. Its simplicity and informative structure is ideal for all new beginners switching to Linux. I am now always on the terminal even for the simplest things. Not only does this build love, but I also get to practice my shell scripting. Great book!!»
«I’ve been enjoying reading the book and have learned a lot from every chapter. Your writing is very clear, and I’ve enjoyed following along with your examples. I’ve skimmed a couple of Linux books before, but never had enough time to really get into them. From those experiences however, I think your book is much clearer and approachable for beginners.»
«WOW! What a great book. It will clearly provide a stepping stone for many people who want to wean themselves off of their GUI habit, or perhaps just «Make the difficult possible.»
«I think one of the greatest assets of the book that most others about Linux don’t have is the conversational tone. I feel like in almost every chapter, there are parts where you lead the reader to ask questions of the material that aren’t necessarily covered.»
© 2000-2021, William E. Shotts, Jr. Verbatim copying and distribution of this entire article is permitted in any medium, provided this copyright notice is preserved.
Linux® is a registered trademark of Linus Torvalds.
Источник
How to Compress PDF in Linux [GUI & Terminal]
Brief: Learn how to reduce the size of a PDF file in Linux. Both command line and GUI methods have been discussed.
I was filling some application form and it asked to upload the necessary documents in PDF format. Not a big issue. I gathered all the scanned images and combined them in one PDF using gscan2pdf tool.
The problem came when I tried to upload this PDF file. The upload failed because it exceeded the maximum file size limit. This only meant that I needed to somehow reduce the size of the PDF file.
Now, you may use an online PDF compressing website but I don’t trust them. A file with important documents uploading to an unknown server is not a good idea. You could never be sure that they don’t keep a copy your uploaded PDF document.
This is the reason why I prefer compressing PDF files on my system rather than uploading it to some random server.
In this quick tutorial, I’ll show you how to reduce the size of PDF files in Linux. I’ll show both command line and GUI methods.
Method 1: Reduce PDF file size in Linux command line
You can use Ghostscript command line tool for compressing a PDF file. Most Linux distributions include the open source version of Ghostscript already. However, you can still try to install it just to make sure.
On Debian/Ubuntu based distributions, use the following command to install Ghostscript:
Now that you have made sure that Ghostscript is installed, you can use the following command to reduce the size of your PDF file:
In the above command, you should add the correct path of the input and out PDF file.
The command looks scary and confusing. I advise copying and pasting most of it. What you need to know is the dPDFSETTINGS parameter. This is what determines the compression level and thus the quality of your compressed PDF file.
dPDFSETTINGS | Description |
/prepress (default) | Higher quality output (300 dpi) but bigger size |
/ebook | Medium quality output (150 dpi) with moderate output file size |
/screen | Lower quality output (72 dpi) but smallest possible output file size |
Do keep in mind that some PDF files may not be compressed a lot or at all. Applying compression on some PDF files may even produce a file bigger than the original. There is not much you can do in such cases.
Method 2: Compress PDF files in Linux using GUI tool
I understand that not everyone is comfortable with command line tool. The PDF editors in Linux doesn’t help much with compression. This is why we at It’s FOSS worked on creating a GUI version of the Ghostscript command that you saw above.
Panos from It’s FOSS team worked on creating a Python-Qt based GUI wrapper for the Ghostscript. The tool gives you a simple UI where you can select your input file, select a compression level and click on the compress button to compress the PDF file.
The compressed PDF file is saved in the same folder as the original PDF file. Your original PDF file remains untouched. The compressed file is renamed by appending -compressed to the original file name.
If you are not satisfied with the compression, you can choose another compression level and compress the file again.
You may find the source code of the PDF Compressor on our GitHub repository. To let you easily use the tool, we have packaged it in AppImage format. Please refer to this guide to know how to use AppImage.
Please keep in mind that the tool is in early stages of developments. You may experience some issues. If you do, please let us know in the comments or even better, file a bug here.
We’ll try to add more packages (Snap, Deb, PPAs etc) in the future releases. If you have experience with the development and packaging, please feel free to give us a hand.
Would you like It’s FOSS team to work on creating more such small desktop tools in future? Your feedback and suggestions are welcome.
Like what you read? Please share it with others.
Источник
How to Use «Script» Command to Record Linux Terminal Session
This script command is very helpful for system admin. If any problem occurs to the system, it is very difficult to find what command was executed previously. Hence, system admin knows the importance of this script command. Sometimes you are on the server and you think to yourself that your team or somebody you know is actually missing a documentation on how to do a specific configuration. It is possible for you to do the configuration, record all actions of your shell session and show the record to the person who will see exactly what you had (the same output) on your shell at the moment of the configuration.
How does script command work?
script command records a shell session for you so that you can look at the output that you saw at the time and you can even record with timing so that you can have a real-time playback. It is really useful and comes in handy in the strangest kind of times and places.
The script command keeps action log for various tasks. The script records everything in a session such as things you type, things you see. To do this you just type script command on the terminal and type exit when finished. Everything between the script and the exit command is logged to the file. This includes the confirmation messages from script itself.
1. Record your terminal session
script makes a typescript of everything printed on your terminal. If the argument file is given, script saves all dialogue in the indicated file in the current directory. If no file name is given, the typescript is saved in default file typescript. To record your shell session so what you are doing in the current shell, just use the command below
It indicates that a file shell_record1 is created. Let’s check the file
After completion of your task, you can enter exit or Ctrl-d to close down the script session and save the file.
You can see that script indicates the filename.
2. Check the content of a recorded terminal session
When you use script command, it records everything in a session such as things you type so all your output. As the output is saved into a file, it is possible after to check its content after existing a recorded session. You can simply use a text editor command or a text file command viewer.
While you view the file you realize that the script also stores line feeds and backspaces. It also indicates the time of the recording to the top and the end of the file.
3. Record several terminal session
You can record several terminal session as you want. When you finish a record, just begin another new session record. It can be helpful if you want to record several configurations that you are doing to show it to your team or students for example. You just need to name each recording file.
For example, let us assume that you have to do OpenLDAP, DNS, Machma configurations. You will need to record each configuration. To do this, just create recording file corresponding to each configuration when finished.
When you have finished with the first configuration, begin to record the next configuration
And so on for the other. Note that if you script command followed by existing filename, the file will be replaced. So you will lost everything.
Now, let us imagine that you have begun Machma configuration but you have to abort its configuration in order to finish DNS configuration because of some emergency case. Now you want to continue the machma configuration where you left. It means you want to record the next steps into the existing file machma_record without deleting its previous content; to do this you will use script -a command to append the new output to the file.
This is the content of our recorded file
Now if we want to continue our recording in this file without deleting the content already present, we will do
Now continue the configuration, then exit when finished and let’s check the content of the recorded file.
Note the new time of the new record which appears. You can see that the file has the previous and actual records.
4. Replay a linux terminal session
We have seen that it is possible to see the content of the recorded file with commands to display a text file content. The script command also gives the possibility to see the recorded session as a video. It means that you will review exactly what you have done step by step at the moment you were entering the commands as if you were looking a video. So you will playback/replay the recorded terminal session.
To do it, you have to use —timing option of script command when you will start the record.
See that the file into which to record is shell_record1. When the record is finished, exit normally
Let’s see check the content of file_time
The —timing option outputs timing data to the file indicated. This data contains two fields, separated by a space which indicates how much time elapsed since the previous output how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays.
Now to replay the terminal session, we use scriptreplay command instead of script command with the same syntax when recording the session. Look below
You will that the recorded session with be played as if you were looking a video which was recording all that you were doing. You can just insert the timing file without indicating all the —timing=file_time. Look below
So you understand that the first parameter is the timing file and the second is the recorded file.
Conclusion
The script command can be your to-go tool for documenting your work and showing others what you did in a session. It can be used as a way to log what you are doing in a shell session. When you run script, a new shell is forked. It reads standard input and output for your terminal tty and stores the data in a file.
Источник