-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinux Server Configuration for Ubuntu .sh
More file actions
68 lines (53 loc) · 2.54 KB
/
Linux Server Configuration for Ubuntu .sh
File metadata and controls
68 lines (53 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
#--------------------------------------#
# Created by: David Odediran
# Date: 10/10/2021
#--------------------------------------#
#--------------------------------------#
# What this script does
#--------------------------------------#
#This script is used to set up a new Linux server with the following configurations:
# 1. Update the system configuration
# 2. Install git
# 3. Create a new user and make them a sudoer
# 4. Create alias for all users
# 5. Set hostname
# 6. Git clone the network configuration script
# 7. Change directory to the cloned repository
# 8. Make the network configuration script executable
# 9. Launch the network configuration script
#--------------------------------------#
# Update the system configuration
# Install git for Ubuntu and Debian
sudo apt-get update -y
sudo apt-get install git -y
echo "Git has been installed."
# Create a new user and make them a sudoer
username="david" # Type your username
# Encrypted password using openssl to generate it
encrypted_password="$(openssl passwd -6 'david1234')" # Type your password
sudo useradd -m -c "David Odediran" -s /bin/bash $username # Type your full name and create a home directory for the user
sudo usermod -aG sudo $username # Add user to the sudo group
echo "$username:$encrypted_password" | sudo chpasswd -e # Set the password for the user
echo "PS1='\u@\h:\w\$ '" | sudo tee -a /home/$username/.bashrc # Set the prompt for the user
sudo -u $username source /home/$username/.bashrc # Source the bashrc file
echo "$username ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/$username # Give the user sudo privileges
echo "User $username has been created and added to the sudo group with sudo privileges."
# Create alias for all users
echo "alias c='clear'" >> /etc/profile # Set alias for all users
echo "Alias 'c=clear' has been set for all users." # Display message
# Set hostname
hostname="CityCat-Server2024" # Type your new hostname
sudo hostnamectl set-hostname $hostname # Set the hostname
echo "Hostname has been set to $hostname."
#Enter the user directory
cd /home/$username
# Git clone the network configuration script
sudo git clone https://github.com/davidblack174/Linux-Server-Configuration
# Change directory to the cloned repository
cd Linux-Server-Configuration
# Make the network configuration script executable
chmod +x "Network-Configuration-for-Ubuntu.sh"
# Launch the network configuration script
sudo bash "Network-Configuration-for-Ubuntu.sh"
echo "Network configuration script has been executed."