Chrome and Chill: Here are 13 basic Linux Commands You Should Know

Chrome and Chill: Here are 13 basic Linux Commands You Should Know

In your journey to discovering the Linux terminal in chromeOS, it is essential that you put the basics to rest for a well-rounded experience as you proceed. I’ll do my best to make the case scenario where these tools really shine in my overview below. Consider this a continuation of our Linux series and connect with Chromies by signing up

nano Command – File Creation and edit

Getting comfortable with the Linux terminal includes you putting in the effort where necessary. If you’re new in the world of Linux, a pretty nifty file editing tool you can’t go wrong with is nano.

nano is a popular small, free and friendly text editor for Linux that also available on chromeOS.

nano is available in the default chromeOS repository and you can simply install it using the command below.

sudo apt install nano
To open a file using nano, type:
$ nano file.txt
$ nano /dir/dir/file.txt

adjust accordingly depending on the directory you’re in.

mkdir command – Directory/Folder Creation

The mkdir command will create a new directory of your choice irrespective of the path.

mkdir "pick_a_name"

apt-get/apt Command

apt-get is a package management system that predates apt which is the current package management shipped by default on Chrome OS. As a flexible and free front-end package manager for Debian/Ubuntu-based systems, apt-get thrives in installing new software packages, removing software packages previously installed, upgrading existing software packages as well as upgrade the entire operating system.

you can install or remove a program by invoking “apt”:
$ sudo apt install packagename
$ sudo apt remove packagename
You can update the packages on your system using the following:
$ sudo apt update

or

$ sudo apt-get update
You can search through the Linux repository using:
sudo apt-cache search packagename
You can upgrade your system using:
$ sudo apt upgrade

or

$ sudo apt-get upgrade
You can autoremove deprecated packages using the command below:
$ sudo apt autoremove

kill Command

In Linux, processes are a means to identifying a service running on your system. They are typically identified by a four-digit number “7630” “8100” “3400”

Using the kill command effectively means killing a process using its PID by sending a signal to it (the default signal for kill is TERM). PID, in this case, is “4400”

$ kill -p 4400
$ kill -SIGTERM -p 4400

cd – change directory

Working in the Linux terminal means that you’re likely to need to navigate around your filesystem. That is, the directory that you’re changing to will now be your current working directory which you can identify using “pwd”

In the example below, “directory-within-parent” may refer to any directory you may have created in your designated user profile. You may also “change directory” cd while logged in as root.

Switching to root in the Linux terminal is simple with the code below:

$ sudo su
$ cd directory-within-parent

pwd – working directory

Sometimes working in the Linux terminal can mean you getting lost within the Linux directory structure. pwd is a command you can quickly type in your terminal to determine the directory you’re currently working in.

$ pwd

killall Command

killall command is used to kill a process by its name. Use this instead of kill if you’d rather not use the PID of the process. If for example the PID of “firefox” is “2500” we can use the “kill” command to end the “firefox” process and conversely, use the “killall” command with “firefox” to end the “2500” PID process.

$ killall firefox

rm command

rm command is used to remove files or directories as shown below. You may use this as an alternative to deleting files and Linux directories in your Chrome OS system.

$ rm filetype
$ rm filetype1
$ rm -rf yourfile

rmdir command

rmdir command helps to delete/remove empty directories as follows. Use it to with care especially if you’re logged in as “root”.

$ rmdir /backup/all

shutdown Command

The “shutdown” command as it suggests will shut down your terminal. It won’t shutdown your Chromebook (no matter how many times I tried) but will shut down a traditional Linux system.

$ sudo shutdown --poweroff

sudo Command

sudo command allows a permitted system user to run a command as root or another user, as defined by the security policy such as sudoers. The sudoers file in the root directory of your Linux system /etc/sudoers.

Accessing this directory as root will enable you to make changes to the sudoers file but it’s highly recommended that you don’t.

With great power comes great responsibility

-Stan Lee

I think this simple quote is quite reflective of the power that comes with sudo. It’s very important that you don’t mess with your file system while logged in as root. You could easily cause irreversible damage if you aren’t careful.

In this case, the real (not effective) user ID of the user running sudo is used to determine the user name with which to query the security policy.

$ sudo apt-cache search audacity
$ sudo apt update
$ sudo passwd [your-username]

wget Command

The internet is pretty much an unending abyss of files waiting to be downloaded. This pretty much translates to the Linux terminal as well. Wget is your savior when it comes to downloading files from the Linux terminal.

wget command is a truly simple Linux utility that you can rely on to efficiently transfer files from the web to your Chromebook using just the Linux terminal.

$ wget -c http(s)://direct-url-path-to-file

zip Command – .zip archives

A common file extension for archived files is .zip with cross-compatibility across operating systems.

zip is a simple and easy-to-use utility used to package and compress (archive) files. using the Linux terminal, you can pretty much create any archive of your choice as indicated in the example below.

$ tar cf - . | zip | dd of=/dev/nrst0 obs=16k
$ zip inarchive.zip foo.c bar.c --out outarchive.zip
$ tar cf - .| zip backup -

You can now support ItsChromeOS News, Videos, Maintenance, and more. Visit donate.itschromeos.com to learn more.