Unix Commands and tricks. (Day 1)
Learning Unix commands are very essential as it helps you to navigate easily in your directories and files. Today we will learn some basics Unix commands which is easy for any beginners to begin with. Also you will get to know some bonus tips in the end.
Let's begin with creating new file.
cat > filename : creates a new file, if files already exists then overwrites it.
cat >> filename: appends the content in the already existing filename, else if not found then creates a new one.
Now to see if file is created or not.
ls -li : long list the files present in that directory with the inode no.
Now if you want to list files which is in some other directory or same working directory then there comes the concept of Relative addressing and Absolute addressing.
Relative addressing and absolute addressing
Relative addressing: here we can move to the directory which is under that directory.
username@hostname directoryname$ cd directory_name
Absolute Addressing: here we specify address from the root
username@hostname directoryname$ cd /home/username/directory_name
Lets play with calendar commands.
cal: prints the calendar of current month
cal mm yyyy : will print calendar of that year of that month.
cal year : will print the calendar of that year
In Unix, you can do calculations as well.
bc: It will open binary calculator. Here you can perform calculations.
Difference between cp (copy) and ln (link) command:
ln filename linkname : it creates a new link pointing to the existing file “file_name”
cp filename newfilename : creates a new file with “newfilename” and then copies the content of the filename into it.
ls -li will confirm that in the copy command there will be different inode number while link command creates a new link to file as they have the same inode no.
mkdir is used to make a directory and
rmdir is to remove a directory
rm file_name: is used to remove a file_name
Till now we learned some basic tips. Time for some Bonus Tips.
passwd : this command is used to change the current password
sudo passwd -l username : to lock that username from the system
sudo passwd -u username: to unlock that username from the system
sudo passwd -e username: to expire the username password next time he logins he has to give new passwd
sudo passwd -d username: deletes the password of that account and sets that account passwordless.