How to practise Linux on a computer you can break
Learn chmod, pipes, grep and cron on a computer where a mistake costs nothing. This post follows a real run: we practised, broke the computer on purpose, asked an agent to fix it, and started again with a clean one.
Most Linux courses ask you to practise as root, on a machine you cannot afford to damage. Many students are afraid to try the risky commands on their own laptop, and that is the right instinct. A computer on awx is separate from your laptop and from everyone else's computers. If you ruin it, you delete it and make another.
We used a Small computer on a test account. We typed the commands ourselves in the Terminal tab, and only called the agent when something broke. Not everything worked the way we expected, and that is in here too.
Make the practice computer
On Computers press New computer. We named it practice-box and kept Small, which is RM0.03 an hour while it runs and nothing while it sleeps. The form also shows the disk (5 GiB) and the system (Ubuntu 24.04).
It was ready in seconds. Open the Terminal tab and you are the user agent, who may use sudo. Notice that the prompt shows the computer's id, computer-3a361b93, and not the name you typed.
Pipes and grep
A pipe sends the output of one command into the next. We counted installed packages, found the biggest folders, and listed the programs using the most memory:
dpkg -l | wc -l # how many lines in the package list
dpkg -l | grep -c python3 # how many lines mention python3
du -sh /usr/* | sort -h | tail -3 # the three biggest folders
ps aux --sort=-%mem | head -4 # the top memory users
/usr/lib is the biggest folder at 1.1 GB.The desktop programs (xfce4-session, Xvfb, xfdesktop) were the top memory users, because every computer has a desktop you can watch. du over /usr took a few seconds, so be patient with it.
Permissions with chmod
We made a file, took away every permission, tried to read it, and gave the permission back:
echo "my secret" > secret.txt
chmod 000 secret.txt # no one may read, write or run it
cat secret.txt # fails, even though you own it
chmod 600 secret.txt # you may read and write it again
cat secret.txt
---------- means no permissions. Being the owner does not help until you change them back.The same screen shows the last grep exercise: grep agent /etc/passwd prints the one line of the user file that mentions agent.
A job that runs every minute
cron runs commands on a schedule. On this computer it was not installed: which cron crontab printed nothing. We installed it, which took 28 seconds, set a job, and started the service by hand:
sudo apt-get update -qq
sudo apt-get install -y -qq cron
(crontab -l 2>/dev/null; echo '* * * * * date >> /home/agent/cron.log') | crontab -
sudo cron
The five stars mean every minute of every hour of every day. After about two minutes the log had two lines:
We started cron ourselves with sudo cron, because nothing starts it for you. A computer that goes to sleep stops every program on it, so you would start cron again after it wakes. We did not test a sleep and wake. If you want something to run while you are away, the Schedules page can run a prompt for you at a set time, as in the morning script post.
How much disk you really have
We made a 2 GiB file to see how disk use is counted, then asked how big our home folder is:
fallocate -l 2G ~/big.bin
du -sh ~ # what our home folder uses
du says our home folder uses 2.1 GB.Use du for this. Its sibling df -h / is tempting, but it shows the disk that your computer sits on, not your allowance, so it tells you nothing about how much you may use. Your allowance is the disk size of the computer (5 GiB here), and 5 GiB across all of your computers, assets and recordings. The Metrics tab shows where you stand:
We deleted the file after this. We did not fill the disk up to the limit. The Settings page says that a computer that goes over its disk limit is stopped and its files are kept, so a runaway file cannot take over the machine.
Break it on purpose
Now the point of the post. The classic way to lock yourself out is to change who owns the system files. We tried two things.
First attempt: a surprise. We removed all permissions from the sudo rules file with sudo chmod 000 /etc/sudoers. sudo kept working. Root can read any file whatever its permissions say, and sudo only checks the owner. A mistake you expect to be fatal is sometimes harmless, and that is worth learning too.
Second attempt: a real lock-out. People often hit "permission denied" inside /etc and fix it by taking ownership of the folder. We did exactly that:
sudo chmod 440 /etc/sudoers # put the permissions back
sudo chown -R agent:agent /etc # the mistake: give /etc to ourselves
sudo whoami
sudo refuses to run on files that a normal user owns.sudo will not trust its rules if a normal user owns them, so it refuses everything. You cannot fix the owner without sudo. We were locked out of our own computer.
Ask the agent to fix it
We opened the Chat tab and told the built-in agent what we had done:
I ran sudo chown -R agent:agent /etc by mistake and now every
sudo command says /etc/sudoers is owned by uid 1001, should be 0.
Can you fix it? If you cannot, tell me exactly why, and what I
should do instead.
The agent ran three commands that only look: who it was and what sudo said, which tools might give it root (su, pkexec), and whether the root account has a password. A fourth command, a search for the Docker socket and for programs that run as root, was marked as risky, so it stopped and asked first:
Read the command before you press Approve. This one only listed things. When we approved it, the step was marked "Failed" and the agent finished with the words "(no reply)". We asked again for a plain answer:
That is the right answer, and a good one to get. The fix it describes is to boot the machine into recovery mode and reset the owner of /etc. We cannot do that: a computer here has no boot menu that you can reach. We did not check each of the agent's claims one by one. What we did confirm is that sudo refused everything we tried.
Start again
The answer on a computer you cannot reboot into recovery is to delete it and make a new one. Settings has a Delete this computer button at the bottom, and it asks first:
We pressed Delete, then New computer again. The new computer was running six seconds after we pressed Create. In its terminal sudo worked, and /etc/sudoers was owned by root again:
sudo works, and the home folder is empty of our mess.Making a computer costs nothing, so a clean start is free. The only thing that costs you is your files, so keep your own work somewhere else. The backup post shows how to save a copy to Assets.
What did not go as planned
- We had to delete two older computers first. A person can have two computers at a time, and our test account already had three from earlier posts. We deleted two of them to make room, so you will not meet this on a fresh account.
- The first break did nothing.
chmod 000 /etc/sudoersdid not stopsudo, as described above. - The agent ended its first run with no reply. It did the work and then stopped without saying anything. A second message got the answer. If a run ends with "(no reply)", ask for a plain answer.
cronwas missing. Not every program you expect is installed.aptadds it in under a minute.- The agent hunted for ways to become root. Searching for programs that run as root is what a person fixing a lock-out has to do, and this was our own computer, so it was fine. On a computer that is not yours, that same search would be a problem.
When a virtual machine on your own PC is better
A computer here is a normal Ubuntu you use through a terminal and a desktop, but it is not a full virtual machine. You cannot boot it into recovery mode, practise a broken bootloader, load kernel modules, or run Docker inside it. If your course asks for those, use a virtual machine on your own PC (VirtualBox or Multipass are free) or WSL on Windows. A computer on awx suits the everyday commands: files, permissions, pipes, scripts, cron, packages, and the mistakes that come with them.
What it cost
The first computer ran for about ten minutes and the second for about two. At RM0.03 an hour that is about half a sen for the first, and the account balance still read RM0.96 afterwards, because the meter takes whole sen. Creating and deleting computers is free. The built-in agent run did not change the balance. The larger limit to watch is storage: our 2 GiB test file used 2.1 of the 5 GiB for as long as it existed. How running time and credit work has the details.
Cautions
- Break only your own computer. Never practise the risky commands on a computer that a team or a project shares.
- Deleting is permanent. Everything on the computer goes, including files and anything you installed. Save to Assets first.
- Read each approval. The agent asks before risky steps. Do not approve a command you do not understand.
- Check your course rules on using an AI agent for practical work.
awxis in early alpha. Keep your own copy of anything that matters.
Keep reading
- How to learn Python and Linux with a tutor beside you
- How to back up and restore a cloud computer: a tested guide
- How to create your first awx computer, step by step
Getting started
Sign in with your Google account and press New computer. Choose Small, open the Terminal tab, and try a command you have been afraid to run.
Awi, signing off.