Giter VIP home page Giter VIP logo

bashprojectfursa's Introduction

Bash Project

Project Goals

In this project, you will implement a bash script which applies default Bash profile configurations for new added Linux users.

This project is aimed for beginners who want to get familiar with Git and GitHub workflows, debug Linux errors and turn Linux commands towards a mature Bash script.

Preliminaries

  1. Fork this repo by clicking Fork in the top-right corner of the page.
  2. Clone your forked repository by:
    git clone https://github.com/<your-username>/<your-project-repo-name>
    Change <your-username> and <your-project-repo-name> according to your GitHub username and the name you gave to your fork. E.g. git clone https://github.com/johndoe/BashProject.
  3. Open the repo as a code project in your favorite IDE (Pycharm, VSCode, etc..).

Later on, you are encouraged to change the README.md file content to provide relevant information about your project.

Let's get started...

Guidelines

In many Linux systems, the /etc/skel directory provides a way to assure new users are added to your Linux system with default Bash profile configurations.

When adding a new user with the adduser command, it will create the user's home directory (usually under /home/<username>), and copy files from /etc/skel to the new user's home directory. Typically, the /etc/skel directory contains a file called .bash_profile. This file, when copied to the user's home directory, can customize the Bash environment of the user.

The /etc/skel directory itself is owned by the root user and has restrictive permissions (mode 755), which means that only the root user can modify its contents.

  1. In /etc/skel edit the .bash_profile file (or create it if it doesn’t exist) using your favorite text editor (nano, vi, etc...) as detailed below. It's highly recommended to backup the original file before you start.
    • Greet the user. E.g. if the username is john, the message Hello john will be printed to stdout.

    • Define an environment variable called COURSE_ID with a value equals to DevOpsFursa.

    • If the file .token exists in the home directory of the user, check its permissions. If the octal representation of the permissions set is different from 600 (read and write by the user only), print the following warning message to the user:

      Warning: .token file has too open permissions
      
    • Change the umask of the user such that the default permissions of new created files will be r and w for the user and the group only.

    • Add /home/<username>/usercommands (while <username> is the linux username) to the end of the PATH env var.

    • Print the current date on screen in ISO 8601 format. The precision should be seconds, and the timezone should be UTC. The correct format should look like: 2022-03-18T08:54:21+00:00.

    • Define a command alias, as follows - whenever the user is executing ltxt, all files with .txt extension are printed (tip: wildcards).

    • If it doesn't exist, create the ~/tmp directory on the user's home dir. If it exists, clean it (delete all the directory's content without removing the dir itself).

    • If it exists, kill the process that is bound to port 8080 (ports will be discussed later on in the course). This resource may help.

    • Feel free to add any additional configurations of yours.

  2. Create a new Linux user using adduser command. If everything is done well, the new user's Bash environment should have the custom script profile you created.
  3. Login to the new user terminal session: su -l <username>. Replace <username> to the created user. Example for the user's terminal behavior might be:
username@localhost:~$ su -l john
Password:
Hello john

Warning: .token file has too open permissions

The current date is: 2022-03-18T08:54:21+00:00

john@localhost:~$ ltxt
a.txt
john@localhost:~$ echo $COURSE_ID
DevOpsFursa
john@localhost:~$ ls -l tmp
total 0
john@localhost:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/john/usercommands
  1. When done, copy the content of your /etc/skel/.bash_profile file into bash_project/.bash_profile in this repo.

Submission

Time to submit your solution for testing.

  1. Commit your changes. The only file that has to be committed is .bash_profile.
  2. Push your commits to GitHub.
  3. In GitHub Actions, watch the automated test execution workflow (enable Actions if needed). If there are any failures, click on the failed job and read the test logs carefully. Fix your solution, commit and push again.

Upon successful test execution, you'll see a green checkmark (✅) and the following message would be printed in the test logs:

Well Done! you've passed all tests

Good Luck

bashprojectfursa's People

Contributors

alonitac avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.