Day12: Linux, Git & GitHub Cheat-Sheet

Day12: Linux, Git & GitHub Cheat-Sheet

Basic Linux Commands with Examples

In this Linux cheat sheet, we will cover all the most important Linux commands, from the basics to the advanced. We will also provide some tips on how to practice and learn Linux commands. This cheat sheet is useful for Beginners and Experience professionals.

1. File and Directory Operations Commands

File and directory operations are fundamental in working with the Linux operating system. Here are some commonly used File and Directory Operations commands:

ls :List files and directories.

  • -l: Long format listing.
  • -a: Include hidden files hidden ones
  • -h: Human-readable file sizes.

  • ls -l? displays files and directories with detailed information.
  • ls -a? shows all files and directories, including
  • ls -lh? displays file sizes in a human-readable format.

cd : Change directory.?

  • cd /path/to/directory changes the current directory to the specified path.

pwdPrint current working directory.?

  • pwd? displays the current working directory.

mkdirCreate a new directory.?

  • mkdir my_directory creates a new directory named “my_directory”.

rmRemove files and directories.

  • -r: Remove directories recursively.
  • -f: Force removal without confirmation.

  • rm file.txt deletes the file named “file.txt”.
  • rm -r my_directory deletes the directory “my_directory” and its contents.
  • rm -f file.txt forcefully deletes the file “file.txt” without confirmation.

cp : Copy files and directories.

  • -r: Copy directories recursively.

  • cp -r directory destination? copies the directory “directory” and its contents to the specified destination.
  • cp file.txt destination? copies the file “file.txt” to the specified destination.

mv : Move/rename files and directories.?

  • mv file.txt new_name.txt? renames the file “file.txt” to “new_name.txt”.
  • mv file.txt directory? moves the file “file.txt” to the specified directory.

touch : Create an empty file or update file timestamps.?

  • touch file.txt? creates an empty file named “file.txt”.

catView the contents of a file.?

  • cat file.txt? displays the contents of the file “file.txt”.

head? :Display the first few lines of a file.

  • -n: Specify the number of lines to display.

  • head file.txt? shows the first 10 lines of the file “file.txt”.
  • ?head -n 5 file.txt? displays the first 5 lines of the file “file.txt”.

tail : Display the last few lines of a file.

  • -n: Specify the number of lines to display.

  • tail file.txt? shows the last 10 lines of the file “file.txt”.
  • tail -n 5 file.txt? displays the last 5 lines of the file “file.txt”.

ln : Create links between files.

  • -s: Create symbolic (soft) links.

  • ln -s source_file link_name? creates a symbolic link named “link_name” pointing to “source_file”.

find : Search for files and directories.

  • -name: Search by filename.
  • -type: Search by file type.

  • find /path/to/search -name “*.txt”? searches for all files with the extension “.txt” in the specified directory.

2. File Permission Commands

File permissions on Linux and Unix systems control access to files and directories. There are three basic permissions: read, write, and execute. Each permission can be granted or denied to three different categories of users: the owner of the file, the members of the file’s group, and everyone else.

Here are some file permission commands:

chmod: Change file permissions.

  • u: User/owner permissions.
  • g: Group permissions.
  • o: Other permissions.
  • +: Add permissions.
  • : Remove permissions.
  • =: Set permissions explicitly.

  • chmod u+rwx file.txt? grants read, write, and execute permissions to the owner of the file.

chown : Change file ownership.?

  • chown user file.txt? changes the owner of “file.txt” to the specified user.

chgrp : Change group ownership.?

  • chgrp group file.txt? changes the group ownership of “file.txt” to the specified group.

umask?: Set default file permissions.?

  • umask 022? sets the default file permissions to read and write for the owner, and read-only for group and others.

Git & GitHub commands


要查看或添加评论,请登录

Shaikh Soheb的更多文章

社区洞察

其他会员也浏览了