Linux was my stepping stone into the world of big data. I still remember the very first class that made the instructor struggle for about 3 hours to help us INSTALL Hadoop. The program itself was beast difficult, but the result was sweet. It took me weeks to figure how to install all those applications that accompany Hadoop in performing its magics. I have later switched to Spark for various reasons, but still visit the Ubuntu environment from time to time to experience its ultra sleek interface with lightning fast performance. Here are some basic commands that new users will find handy to get started with:
#Some fun commands I liked to run before going to the main course:
$ whoami
and
$ finger
#Running a command with superuser control e.g. adding a new user to the system:
$ sudo useradd username
#which will ask to set a strong pw:
$ sudo passwd username
#Making a text file using the cat comand:
#Printing current directory:
$ pwd
#Getting the list the items in the current directory
$ ls
#Change current directory
$ cd ‘newdir’
#Remove a file:
rm ‘file-to-remove’
#Remove an empty folder/directory using the recursive specification:
$ rm -r ‘directory-to-remove/’
#Remove a directory plus its contents:
$ rm -rf ‘directory-to-remove/’
#Relocate a file
$ mv ‘file.txt’ ‘target-folder/’
#Make a new directory
$ mkdir ‘newdirectory’
#Make a child directory under a specific parent directory
$mkdir /olddir/newdir
#Force exit a program: Enter ‘top’ in terminal to get the process id of the program, then type
$kill ‘process id’
#Or by the name of the program using the pkill command:
$ pkill firefox
#To print the last 25 commands:
$ history 25
#Checking installation path of an app
$ which ‘whatever application’
e.g.
which mongo
#returns
#Installing an app e.g. zoom:
$sudo apt update
$sudo snap install zoom-client
#To launch:
$ zoom-client
#Download something from web
$ wget ‘weblink’
#Here is the link to get R studio
$wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2022.02.1-461-amd64.deb
#Shutdown
$ shutdown -h now
#Shutdown in 95 minutes
$ shutdown -h 95
#Or at 10:48 pm
$ shutdown -h 20:48
Setting file/folder permissions ( Linux’s way of saying hi!)
#Available flags:
400 r Readable by owner only
500 r-X Avoid Changing
600 rW Changeable by user
644 rw-r–r Read and change by user
660 rw-rW Changeable by user and group
700 WX Only user has full access
755 rwxr-xr-X Only changeable by user
775 rwxrwxr-X Sharing mode for a group a
777 rwxrwxrwx Everybody can do everything
#e.g. making a file readable, writeable and executable by everyone.
chmod 777 ‘filepath’
#making all files in dir readable, writeable and executable by everyone.
chmod -R 777 ‘filepath’
or
chmod -R 777 ./
#The next is a favorite one of mine, running several comands at once. The semicolon ‘;’ operator is used to run several commands in sequence irrespective of the successful execution of any in the queue.
#The ‘&&’ operator is used to run commands conditional on the successful execution of the last one.
#The third one ‘||’ is used when the goal is to move to the next command only if the last one has not succeeded. I will show an example of the first one by installing MongoDB which is a fantastic NoSQL app that offers great features such as fault tolerance, scalability, and easy navigation of inherently complex relational databases such as those seen in patient or hospital documents.
#Installing MongoDB: Just dump the following into terminal and hit enter:
wget -qO – https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -; echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list; sudo apt-get install -y mongodb-org; sudo systemctl start mongod
#If all went well, you should be able to launch mongo shell just by typing ‘mongo’
To get started, just print the existing databases by ‘show dbs’ and then open a new one using the ‘use’ command as shown below:
#We will add just one observation: