Книга: Linux Command Line: An Admin Beginners Guide
Назад: The Underpinning of Linux Security
На главную: Предисловие
CHAPTER NINE: Project Ideas, More Commands, and Closing...
Project Ideas, More Commands, and Closing Thoughts
Quiz Time!
Close your notebook first and try to answer as many of the following questions as you can without looking at what you wrote down. If you are unable to answer certain questions, mark them with an "x" or a checkmark and calculate your score.
Once you finish giving yourself the quiz, you may look in your notebook and answer the questions you were previously unsure about.
Ready? Let's begin.
Linux Installation
  1. When installing Linux, what kind of file should you download to make sure it installs correctly on your virtual machine?
  2. True or false: Google Chrome is an operating system built on a kernel of Linux.
  3. True or false: Arch Linux was created to offer Linux users the Linux experience without all the extra "bells and whistles" that could cause clutter and may ultimately be unneeded for certain projects.
Basic Files and Directories
  1. What is the difference between the root folder and the root user?
  2. Is there any danger when storing files in the root directory in Linux?
  3. What does the lib library file contain?
  4. Is capitalization important in Linux syntax?
Linux Shells
  1. What is a shell? How is it different from a terminal?
  2. What is a GUI interface? How is it different from a command line interface?
  3. Is a desktop environment GUI or CLI?
  4. What is the main difference between Bash and csh?
  5. Do all Linux operating systems come with a desktop environment?
The Command Line
  1. What does cd stand for? How is it used?
  2. What's the difference between the absolute path and the relative path?
  3. If you wanted to know the absolute path of your current working directory, which command would you use?
  4. What does the pwd command stand for? What does it do?
  5. Which command would you use if you wanted to know a file's type?
  6. What are some features of the vim text editor?
Manipulating Files
  1. How would you move a file from one directory to another?
  2. How would you copy a file?
  3. If you don't want a file on your system anymore, which command would you use to remove it?
  4. How would you remove an empty directory?
  5. How would you remove a full directory?
  6. Name some ways to view the contents of files.
  7. How would you create a blank file?
  8. What does the cat command do?
  9. Which command would I use if I wanted to print text to the screen?
  10. How is the less command different from the more command?
  11. If I wanted to view the last five entries of a list, which command could I use?
  12. If I wanted to view the first five entries, which command could I use?
More Advanced Commands
  1. Which command could I use if I wanted a list of all files with a certain title?
  2. Which command could I use if I wanted to search for a file with a certain title?
  3. The command grep stands for what? What is grep used for?
  4. Which command could I use if I wanted to know how many words, lines, and bytes a document contains?
  5. What are wildcards? What do they do when added to a command?
Files and Directories
  1. What are two ways to compress a file in Linux?
  2. Which commands could I use if I wanted to compare two files?
  3. Which command could I use to display directories and subfolders?
  4. How could I download a file from the command line without using sudo apt-get?
Other Commands
  1. Which command could I use if I wanted to know if a website is responding?
  2. Which command could I use to create my own shortcuts or custom terminal commands?
Help Commands
  1. What are some advantages to using the man command over the --help option?
Understanding Linux Security
  1. What is the sudo command, and how is it used?
  2. How does a root user differ from other users?
  3. What is one potential security problem about how Windows grants permission to programs? How does Linux solve this?
Files and Directories
  1. What does rwx stand for? Why is having permissions for files and users important?
Users and Groups
  1. What's the difference between chmod and chown?
  2. How would you set the user ID?
  3. How would you set the group ID?
Processes and Jobs
  1. What's the difference between a process and a job? Give an example of each.
  2. What are some potential advantages of the sleep command?
Foreground, Background, and Killing Jobs
  1. How do you put a process that is already running into the background?
  2. How do you tell a process to go to the background at the time you run it?
  3. How do you kill a process?
Linux System and User Management
  1. What does the top command do?
  2. What does df do? How is it different from du?
  3. How would you check to see how much disc space you have?
  4. How would you check to see who is logged on to your network?
  5. How would you find your hostname?
  6. What are quotas, and who can edit them?
  7. How would you add a user? How would you remove a user?
  8. How would you change a user's details?
Passwords
  1. What does the chage command do? How is it different from the passwd command?
  2. What's an easy way to set a date of expiration for a password?
Groups
  1. How would you add a group? How would you remove a group?
Now, tally up your score. Round to the nearest tenth if needed. How did you do?
If you got 100% of these questions correct, great job! You might know the basics of the Linux command line now, and you might be ready to take on more complex and advanced projects.
If you scored below 100%, make a note of all of the questions you missed and go back to the chapters where they are found and look them over. Keep practicing on the command line until you feel comfortable with all of the commands.
Project Ideas
Now that you have a general idea of the Linux file system and how it is structured, along with how to use its basic commands and options, you may want to further your learning by attempting some basic projects.
Basic-Beginner Friendly
Continue Bash
You might want to continue learning the Bash scripting language and try your hand at writing more complex commands. You may even try creating a labor-saving program or two. Such a project will likely require commands like alias and grep, combined with techniques like piping. After getting familiar with stringing basic commands together, you can start to use conditional checks and loops to really power up your scripts.
Let's pretend you want to write a program to find the text files in the current directory and limit the result to 2 files.
You might be able to use simple commands like this when creating automated messages, such as for group emails, and there are many other things you could do with the commands you've already learned as well. Searching on the internet is a great way to get an idea of the things you could do. Type in something like "scripting basic programs in the Bash shell" and click on the links, tutorials, or videos that interest you. If you have a specific project in mind, tailor your search to your specific needs.
Give yourself some more practice with piping and using grep. Mix commands together or apply the commands you know to a project to expand your learning and get an idea of how it all fits together.
Learn the Basics of a Programming Language
Python
You may be surprised to find out that a lot of programs in the Linux environment are created using the Python scripting language. Many distributions of Linux come with Python pre-installed, and distros of Linux that might have been made especially for aspiring programmers and hobbyists, such as Raspbian, may even have Python programming tutorials as standard desktop programs.
Improve your coding knowledge by taking the next step and learning how to write a simple program that can be run on your Linux machine.
Some suggestions for where to start may include just doing an internet search for "learn Python." You may find many free tutorials among paid options, or you can purchase or borrow an ebook, via Amazon's Kindle Unlimited service for example.
Feel confident about tackling your next project.
C and C++
To use other Linux features, you might want to learn some basics of the C programming language. Doing so will enable you to enter commands into the csh shell, as mentioned before. You may also learn how to write programs and apps for the Linux OS.
Set up a Raspberry Pi Project
Raspberry Pi is a simple mini-computer that may be small enough to fit into the palm of your hand. Don't let its size fool you; it can still be used to build amazing projects.
Simple All-in-One Computer
Have you ever wanted an "all-in-one" desktop computer (computers that come with the monitor and all of the hardware right out of the box and don't have to be connected to a tower), but thought they were prohibitively expensive? Good news! You can now create something fairly similar by setting up a Raspberry Pi mini-computer and hooking it up to an old LCD computer monitor.
For this project, you need to know how to:
This project is relatively easy to complete--merely put together a Raspberry Pi by use of the build kit that came with your Pi. If you need help, a quick internet search should provide plenty of instructional videos.
Next, write a memory card with Raspbian if your build kit didn't already come with one.  Insert the memory card that you wrote with the Raspbian operating system, then hook it up to power and boot it up.
Use a USB wand or dongle to connect the Pi to a monitor and anchor it in place. You now have a functional, "all-in-one" computer with no visible tower and wireless connectivity capability. Practice surfing the web and installing new programs on it. If you need expanded storage space, external hard drives are available and should connect with a standard USB port.
Intermediate
Set Up a Small Home Server
You don't have to wait until you learn a full coding language to do something productive in Linux. If you have a small computer that you aren't using and want to re-purpose, you could set up a home server for added security on your own network.
Before we get started, here are some of the commands that you might need to know:
Step One: Select a computer to act as a server
Use a small computer for this project, either an old outdated computer or a Raspberry Pi mini-computer. You can increase the physical storage via external hard drives, and don't think you need a computer with a lot of RAM or processing power to act as your server.
Step Two: Install Linux
Use a USB copy of Debian or a version of Linux configured especially for server use. Put the USB copy of the program into the USB port of the computer you want to re-purpose as a server, and go through the prompts of the install. Select the server version, then select the LAMP package install.
LAMP stands for "Linux, Apache, MySQL, PHP." Having these packages pre-installed during set-up will allow you to skip a few steps in the configuring process. You may elect to give your project a desktop environment, or you may decide that you don't need one and choose to keep it as only a command line.
Go through the installation process and follow the prompts to set everything up.
Step Three: Downloads
Open your command line and type:
Remember that sudo can be read to mean "super user do," and it may be a way of getting permission to perform administrative tasks that Linux would otherwise block you from doing.  Try entering all of the commands separately rather than all at once.
Step Four: Enter the IP Address
Replace "ubuntu" with the name you want to use for your server, and enter your static IP address. If you don't know it, use the hostname command with the -i option.
That's it--you're now ready to turn this into a private server to store and remotely access home media files, such as pictures, music, videos, and more while keeping your data secure and free from the data-mining practices of cloud sharing sites. If you want, you can take a few additional steps and turn it into a web hosting server and have people pay you to host their websites.
Before you do this, you may want to learn one more command, however.
tasksel
Explanation:
This command stands for "task select" and is intended for those who want to use Ubuntu Linux for servers. If you know exactly what you want your server to do, you can just run the tasksel command to install the software you need to create a specific server. 
To use the tasksel command, type sudo tasksel. You may need this command once you set up your server.
Now, go make that server!
Advanced
The Internet of Things , or IoT, is fascinating. You can connect drones, wireless "smart" cameras, and even create small robotic appliances that send messages to a server to let you know their status. You could use IoT technology for many things, including vending machines that can sense when their inventory is low and can signal you to order more, eliminating the need for you to check them by hand. A popular use for this technology is the smart camera.
You can try making your own, small IoT project, like remotely connecting a Linux terminal to program a headless system to power a robot or remote-controlled camera. You might need to know Python and have a good idea of how to connect wirelessly to a Linux machine, as you probably don't want your new machine to have to receive commands via a terminal you have to access through a screen on the machine itself.
For this project, you might need to know how to:
For more information on this, look up some drone and small robot builds. You may need special cables and some programming knowledge to get your creations to do what you want. Unfortunately, this book won't be covering much about programming languages outside of what you may need to know for basic Bash scripting. If you believe you're ready to tackle a larger project, don't let any of this discourage you--there are plenty of free resources on the web about getting started with the exciting world of AI. You may even find communities that will help you with your builds and projects, even providing step-by-step tutorials. There are various places to post questions for community feedback too, so you should definitely try it out if this interests you.
Suggestions for Further Reading 
It depends on what you want to know. After reading this book, you should now have a working knowledge of how to navigate the Linux terminal and enter simple commands. With the use of tutorials, you can create some pretty amazing builds.
If you want to get into programming, you will need to have a good grasp of a programming language like Python, and you need to get more comfortable entering commands into the Bash shell.
The exercises included in this book were very basic and not challenging at all, but the main focus was getting you used to the command line. To truly start programming in Linux, you need to then take the little bit that you've learned and expanded upon it. Look for resources and tutorials everywhere, and practice writing and executing small programs. Apply yourself like a dedicated student, and you will make amazing progress.
Remember, you've gotten all the foundations. Now, all you need to know how to do is put the building blocks together to create more impressive programs. Start out slow, then work your way up. Build small projects until you get comfortable with larger ones.
Closing Thoughts
I hope you've enjoyed this book, appreciate Linux a little more, and find the Linux command line less intimidating. If this book has helped you, consider leaving a five-star rating on Amazon and Goodreads, and don't forget to share this book with a friend who wants to learn Linux too.
Назад: The Underpinning of Linux Security
На главную: Предисловие