Basic Linux Commands Study Guide
Basic Linux Commands Study Guide
Basic Linux commands are beneficial to developers when interacting with a Linux operating
system through the command line interface. They are used when working with files and
directories. Typically, they are easy to learn and apply, and provide developers with
additional commands for more advanced situations. If needed, these commands are also
easy to look up on your preferred search engine.
In this reading, you will review basic Linux commands with examples provided along the
way.
mv
mv is used to move one or more files to a different directory, rename a file, or both at the
same time.
Note: Linux is case-sensitive, so mv can also be used to change the case of a filename.
Examples:
cp
cp is used to copy one or more files.
Examples:
chmod/chown/chgrp
chmod/chown/chgrp is used to make a file readable to everyone on the system before
moving it to a public directory.
Example:
cut
cut is a command that extracts fields from a data file.
Examples:
cut -f1 -d",", addressbook.csv # Extract the first field from a CSV file.
cut -c1-3,5-7,9-12 phones.txt # Extract specific characters from a phone number list.
sort
sort is a command that sorts the contents of a file.
Examples:
ls -l | cut -w -f5,9 | sort -rn | head -10 # Display the 10 largest files in the current
directory.
cut -f1-2 -d"," addressbook.csv | sort # Extract and sort first and last names from a CSV
file.
Additional commands
id
id is a command that prints information about the current user.
Example:
$ id
uid=3000(tradel) gid=3000(tradel)
groups=3000(tradel),0(root),100(users),545(builtin_users),999(docker)
free
free is a command that prints information about memory on the current system.
Example:
Key takeaways
Basic Linux commands assist developers in different types of tasks related to managing files
and directories and working with the content of each file. These commands allow
developers to work more efficiently and effectively.