There are thousands of linux/mac commands. But you only need to know less than a dozen commands to get by as a new developer. Here are the top 10 command line commands every new developer should know.

ls – List Content

You can’t do anything if you cannot ‘see’. ls (LS not is) allows you to ‘see’ what files and folders are in your current directory. It’s a uber popular and maybe the most used command.

screenshot of running an ls command in mac terminal.
ls output example

pwd – Present/Print Working Directory

If ls is the what pwd is the where. pwd shows you where you are in the file system. It shows you the path to your current location.

A screenshot of running pwd within a mac terminal
pwd output example

cd – Change Directory

Sometimes we just need a change of scenery. cd allows you to change your current directory. The format is

cd location

Here are some examples of ls commands.

  • To move up one directory or move into the parent directory
    • cd ..
  • To move into another directory in the current location
    • cd nameOfDirectory
  • To move to the root directory (whatever that might be)
    • cd ~
  • To move multiple levels
    • cd nameOfDirectory/nameOfAnotherDirectory
Screenshot of running pwd then ls then cd documents and finally pwd.
cd Example

cat – concatenate

What if you quickly wanted to see the content of the file without having to open it? Well, cat can be used for that. The syntax is:

cat filename
Screenshot fo running cat output.txt
cat command example

touch – Create new File

When you touch something you create it. So when you would like to create a file (a different command is used for folders) you simply run touch followed by the filename you would like to give it. So the syntax is:

touch New_File.java
Screenshot of running mkdir temp then cd temp then touch New_File.java and finally ls
touch example

mkdir – Make Directory

mkdir is the touch of directories. mkdir creates an empty folder.

mkdir folderName
Screenshot of running mkdir school_work then ls then cd school_work
mkdir example

rm – Remove File

We have seen, moved, created now comes deleting. To delete a file run rm followed by the name of the file.

rm nameOfFile.extension
Screenshot of running ls then rm New_File.java and the ls
Example of Running rm

rm -r – Remove Folder

What about folders you ask? Simply add the -f flag. So…

rm -r folderName
Screenshot of mkdir Coding_Stuff then ls followed by rm -r Coding_Stuff and finally ls
rm -f to Remove Folder Example

mv – Move File/Folder

Not satisfied with where all your files and folders are? You can move them! The syntax is:

mv fileOrFolderName NewLocation

Below is a screenshot of moving a folder into another folder

Screenshot of running ls then mv Coding_Stuff/ school_work/ followed by ls
mv folder example

sudo – Super User Mode

Privilege issues is one of the most common problem when working within the command line. To overcome it run any command with the word sudo in front of it. You might have to enter your system/root password when executing the command.

sudo command
Screenshot of sudo mkdir New_Folder entering password then ls
sudo example

BONUS: git

Developing code without version control is like constructing a house without insurance. You can do it but it is not very smart.

Using git to backup your code to gihub is just a smart thing to do. Here are the most popular git commands:

git init
git status
git pull origin master
git remote
git add .
git commit -m "What have you done since the last commit"
git push origin master

git init – initiated the current directory to be a git repository (not common)

git status – check the status of repository (common)

git pull origin master – Pull code from remote repository (not common)

git remote – check the names of all remote repositories (not common)

git add . – Add all files to be staged (common)

git commit -m “describe what has changed” – commit to staging area (common)

git push origin master – push all changes to remote repository (common)

Screenshot of git status, touch newFile, git status, git add ., git commit -m "Added a new file" and finally git push origin master
git commands example

That’s it. You don’t need to get a phd in command lines to be an effective developer. You just need to know the commands above. Also, you might need to look up additional flags or parameters to execute special cases.

Please follow and like us:
error