Lately I’ve been spending a lot of time thinking about my career and where it’s going. I don’t want to give the impression that I have never thought about my career before, but now the thoughts are becoming constant.
When I started working with Linux, I was completely lost. I'm a windows developer. I work with the .NET Framework. Talking about a huge leap and learning curve, it took hours upon hours to figure out how to even start working with it. So to help the lost and helpless (like myself), I have compiled a list of common commands that you will need as you fumble through linux. This is not an exhaustive list by any stretch but hopefully it will be a good start.
Prefix this command with any other command and it will run the command with elevated rights. This is one of the most important "commands" you'll use, so memorize it!
sudo apt-get bluetooth
Change the working directory. You will be moving around the system a lot. There are different ways to move around the system.
cd /home/pi # change directory from the root cd ~/tmp/directory # change directory from the user's directory cd .. # step down 1 directory cd tmp/directory # change directory to tmp/directory from the current working directory cd ./tmp/ # same as above but can be useful when executing scripts
Clears the working screen. Helpful when too much is happening and you need a fresh slate.
Copies a file or directory to another location
cp ~/tmp ~/new-folder # Copies Directory cp ~/main.tgz ~/main-copy.tgz # Copies File
Searches for a file against a specified pattern. There are a number of options available. The -name option can allow wildcard searches.
find ./test/abc.txt # Find abc.txt in test directory find . -name "*.txt" # Find all .txt files in the current directory
Searches a file for text. Useful if you're trying to find something in a fairly large file
grep 'word' filename # Find word in the given filename grep -i 'word' file1 file2 # Find word in the file1 and file2 while ignoring case grep -r 'word' /directory/ # Find word in any file in the directory (recursive) grep -w 'word' filename # Search for the word using a whole word search grep -n 'word' filename # Search for the word and show the given line number
List all files/directories. I use this all the time to see where I'm at and confirm files are created, etc.
ls # List all files/directory in the current directory ls /directory/ # List all files/directories in the defined directory
Creates a new directory
mkdir new-directory # Creates a new directory in the current directory mkdir ~/tmp/new-directory # Creates a new directory under the tmp directory
Rename or Move a file/directory
mv ~/tmp/old.txt ~/tmp/new.txt # Renames a file from old.txt to new.txt mv ~/tmp ~/new-tmp # Renames a directory from tmp to new-tmp mv ~/tmp/old.txt ~/ # Moves old.txt to the user home directory
Removes (deletes) a file/directory
rm ~/tmp/old.txt # Delete old.txt rm -r ~/tmp # Removes all files/directories in the tmp directory
Advanced Packaging Tool. This is an incredibly powerful tool to get new packages installed on a linux box. There are too many possibilities to show them here, but you should definitely investigate it more (Reference: http://www.tecmint.com/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management/)
sudo apt-get update # Update all packages based on indices sudo apt-get upgrade # Upgrade all packages currently installed sudo apt-get install bluetooth bluez # Install bluetooth and bluez packages sudo apt-get install "*blue*" # Install all packages with blue in the name sudo apt-get remove bluetooth # Uninstall bluetooth package (leave config) sudo apt-get purge bluetooth # Uninstall bluetooth package including configs
Retrieves a file from the web and downloads. (Reference:http://www.tecmint.com/10-wget-command-examples-in-linux/)
wget http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz # Downloads tar to current directory wget -O filename.zip http://<uri>/crazy-file-name.zip # Downloads file and names it filename.zip
Yellowdog Updater Modified. This is another package management tool. It is used more for GUI applications but not always.
yum install firefox # Installs Firefox yum remove firefox # Uninstalls Firefox yum update mysql # Updates MySQL yum search wget # Searches for the wget package yum list installed | less # List all installed packages yum list | less # List all available packages yum update # Updates all installed packages
Typical Git command. If you know anything about git commands, this should be familiar. Like many of these, there is too many to show (Reference: https://git-scm.com/docs)
git clone http://<uri>/project.git # Clone project.git into the current directory git pull # Pull commits into current directory git push # Push commits to the repository git fetch # Fetch to the repository
There are plenty of other commands and for every package you download, you have more to work with. I hope this simple list can help you get started. This post will be a "living document" and will be updated multiple times. Let me know in the comments if you need better examples or more.
Check out our thoughts here.
There is one, and only one, primary focus that any software developer acknowledge: the ability for software to be maintainable. Of course, correctness, functionality, and performance are all important, these will always be easier to address with maintainable software.